diff --git a/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681159605375880466/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681159605375880466/config.json b/scripts/7681159605375880466/config.json new file mode 100644 index 0000000000000000000000000000000000000000..71638ee24866fda1130d69e1044891bcce896013 --- /dev/null +++ b/scripts/7681159605375880466/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AEExporter:1.5.5", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903134318663", + "version": "14.8.0", + "item_source": "user_post_pc_le" +} \ No newline at end of file diff --git a/scripts/7681159605375880466/extra.json b/scripts/7681159605375880466/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681159605375880466/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/content.json b/scripts/7681165424754429202/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/JSSys.js b/scripts/7681165424754429202/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +1 @@ +const{ShaderPass}=require("./ShaderPass.js");const getCurrentScene=require("./three-amg-wrapper.js").getCurrentScene;const RenderPass=require("./RenderPass.js").RenderPass;const Texture=require("./wrapper/Texture").Texture;const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class EffectComposer{constructor(renderer){this.renderer=renderer;this.passes=[];this.scene=getCurrentScene();this.rt_0=this.scene._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this.rt_prev_Texture=null;this.rt_next_Texture=null;this.sourceEntity=this.scene._amgScene.findEntityBy("PerspectiveCamera_w");this.sourceCamera=this.sourceEntity?this.sourceEntity.getComponent("Camera"):null;this.outputEntity=this.scene._amgScene.findEntityBy("Camera")||this.sourceEntity;this.outputCamera=this.outputEntity?this.outputEntity.getComponent("Camera"):null;this._outputIsPerspective=!!(this.outputEntity&&this.outputEntity.name==="PerspectiveCamera_w");this._initialInputTexture=this.rt_0;this._currentInputTexture=this._initialInputTexture;this._ppPassCount=0;this.finalPlaceHolder=this.scene._amgScene.findEntityBy("PlaceHolder");this.outputRT=this.scene._amgScene.assetMgr.SyncLoad("rt/outputTex.rt");if(this.sourceEntity){this.sourceEntity.layer=0;if(this.sourceCamera){this.sourceCamera.renderOrder=0;this.sourceCamera.renderTexture=this.rt_0}}}_getStartOrder(){let startOrder=0;for(let i=0;i{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..ccd60305239e0288e9bb4f4f40a388f8a615a7c5 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,117 @@ +const TWEEN=require("./tween");const customEasings=require("./customEasings").customEasings;const THREE=require("./three-amg-wrapper").THREE;const{ShaderPass}=require("./ShaderPass.js");class ScriptScene{constructor(amgScene=null,container=null){if(amgScene){this.scene=new THREE.Scene;this.scene._amgScene=amgScene}else{this.scene=new THREE.Scene}this.effect_type="transition";this.camera=null;this.renderer=null;this.scene.background=new THREE.Color(3355443);this.isAnimating=false;this.animationFrameId=null;this.sceneObjects=null;this.texture1=null;this.texture2=null;this.composer=null;this.renderPass=null;this.usePostProcessing=true;this.initCoreObjects();if(container){this.init(container)}}destroy(){this.isAnimating=false;if(this.animationFrameId!==null&&typeof cancelAnimationFrame!=="undefined"){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}if(this.renderer){this.renderer.setAnimationLoop(null);this.renderer.dispose();if(this.renderer.domElement&&this.renderer.domElement.parentNode){this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}if(this.texture1){if(typeof this.texture1.dispose==="function")this.texture1.dispose();this.texture1=null}if(this.texture2){if(typeof this.texture2.dispose==="function")this.texture2.dispose();this.texture2=null}if(this.scene){this.scene.dispose()}if(typeof window!=="undefined"){window.removeEventListener("resize",this.handleResize)}if(this.sceneObjects&&this.sceneObjects.tweens){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.stop==="function"){tween.stop()}});this.sceneObjects.tweens=[]}if(this.shaderPasses&&this.shaderPasses.length){this.shaderPasses.forEach(pass=>{if(pass&&typeof pass.dispose==="function"){try{pass.dispose()}catch(e){}}});this.shaderPasses=[]}if(this.shaderPass&&typeof this.shaderPass.dispose==="function"){try{this.shaderPass.dispose()}catch(e){}}this.shaderPass=null;if(this.composer){this.composer.dispose();this.composer=null}this.renderPass=null;this.scene=null;this.camera=null;this.renderer=null;this.sceneObjects=null}initCoreObjects(){if(typeof window!=="undefined"){if(!window.innerWidth||!window.innerHeight){window.innerWidth=600;window.innerHeight=600}window.devicePixelRatio=window.devicePixelRatio||1;if(this.scene&&this.scene._amgScene&&this.scene._amgScene.assetMgr){const inputTexture=this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");if(inputTexture&&inputTexture.width>0&&inputTexture.height>0){window.innerWidth=inputTexture.width;window.innerHeight=inputTexture.height}}}this.camera=new THREE.PerspectiveCamera(53.1,window.innerWidth/window.innerHeight,.1,1e4);this.camera.position.z=10;this.scene.add(this.camera);if(this.scene._amgScene==null){this.renderer=new THREE.WebGLRenderer({antialias:true});this.renderer.outputColorSpace=THREE.LinearSRGBColorSpace}if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight);this.renderer.setPixelRatio(window.devicePixelRatio)}this.sliders={};this.TWEEN=TWEEN;this.customEasings=customEasings;this.Duration=2e3}addShaderPass(shaderPassConfigs){if(!Array.isArray(shaderPassConfigs)){shaderPassConfigs=[shaderPassConfigs]}shaderPassConfigs.forEach(config=>{const atomicName=config.name;const className=atomicName.startsWith("Lumi")?atomicName.substring(4):atomicName;const shaderPassModule=require("../pp/Lumi"+className+"/"+className+"ShaderPass.js");const ShaderPassClass=shaderPassModule[className+"ShaderPass"];const initConfig=config&&(config.initConfig||config.config||config.params)||{};const shaderPass=new ShaderPassClass(initConfig);this.composer.addPass(shaderPass);this.shaderPasses.push(shaderPass)})}setupPostProcessing(shaderPassConfigs){const{EffectComposer}=require("./EffectComposer.js");const{RenderPass}=require("./RenderPass.js");this.composer=new EffectComposer(this.renderer);this.renderPass=new RenderPass(this.scene,this.camera);this.composer.addPass(this.renderPass);this.shaderPasses=[];this.addShaderPass(shaderPassConfigs)}initPostProcessing(){}init(container){if(this.renderer){if(container){container.appendChild(this.renderer.domElement)}else if(typeof document!=="undefined"){document.body.appendChild(this.renderer.domElement)}}if(typeof window!=="undefined"){window.addEventListener("resize",()=>this.handleResize())}}start(updateCallback){if(this.isAnimating)return;this.isAnimating=true;if(updateCallback){const animateFrame=()=>{if(!this.isAnimating)return;updateCallback();this.animationFrameId=requestAnimationFrame(animateFrame)};animateFrame()}else{this.renderer.setAnimationLoop(()=>{this.update()})}}updateScene(timestamp){if(!this.isAnimating){this.isAnimating=true}this.defaultUpdate(timestamp)}update(){if(this.usePostProcessing&&this.composer){if(this.renderPass){this.renderPass.camera=this.camera}this.composer.render()}else if(this.renderer){this.renderer.render(this.scene,this.camera)}}handleResize(){this.camera.aspect=window.innerWidth/window.innerHeight;this.camera.updateProjectionMatrix();if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight)}if(!this.isAnimating){this.update()}}loadTextures(){const textureLoader=new THREE.TextureLoader;return Promise.all([new Promise(resolve=>{this.texture1=textureLoader.load("image/Sample1.jpg",resolve);this.texture1.colorSpace=THREE.LinearSRGBColorSpace;this.texture1.wrapS=THREE.RepeatWrapping;this.texture1.wrapT=THREE.RepeatWrapping}),new Promise(resolve=>{this.texture2=textureLoader.load("image/Sample2.jpg",resolve);this.texture2.colorSpace=THREE.LinearSRGBColorSpace;this.texture2.wrapS=THREE.RepeatWrapping;this.texture2.wrapT=THREE.RepeatWrapping})])}_applyTweenInitialState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,0);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,0)}}_applyTweenFinalState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,1);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,1)}}seekToTime(time){if(!this.isAnimating){this.isAnimating=true}const clampedTime=Math.max(0,Math.min(time,this.Duration));if(this._predef_seekShaderPass){this._predef_seekShaderPass(clampedTime)}if(!this.sceneObjects.tweens||this.sceneObjects.tweens.length===0){return}let notStartTweens=[];let runningTweens=[];let finishedTweens=[];for(let i=0;i<=this.sceneObjects.tweens.length-1;i++){const tween=this.sceneObjects.tweens[i];let TweenStartTime=tween._delayTime+10;let TweenEndTime=tween._delayTime+tween._duration;if(clampedTime<=TweenStartTime){notStartTweens.push({time:TweenStartTime,tween:tween})}else if(clampedTime>=TweenEndTime){finishedTweens.push({time:TweenEndTime,tween:tween})}else{runningTweens.push(tween)}}notStartTweens.sort((a,b)=>b.time-a.time);finishedTweens.sort((a,b)=>a.time-b.time);notStartTweens.forEach(item=>{this._applyTweenInitialState(item.tween)});finishedTweens.forEach(item=>{this._applyTweenFinalState(item.tween)});runningTweens.forEach(tween=>{tween.stop();tween.start(0);tween.update(clampedTime)});this.update()}setupScene(){this.initSceneObjects();this.scene.background=null;this.createMainPlane();this.setupAnimations();return this.sceneObjects}initSceneObjects(){this.Duration=2e3;this.camera.position.set(0,0,10);this.camera.lookAt(new THREE.Vector3(0,0,0));this.sceneObjects={tweens:[],meshes:{},materials:{},uniforms:{}}}createMainPlane(){if(!this.texture1||!this.texture2){return}const geometry=new THREE.PlaneGeometry(10,10,200,200);const material=new THREE.ShaderMaterial({name:"LiquidWarpMaterial",uniforms:{texture1:{value:this.texture1},texture2:{value:this.texture2},u_turbulenceStrength:{value:0},u_displaceSweep:{value:0},u_directionBlurIntensity:{value:0},u_mixFactor:{value:0},u_revealRadius:{value:0},u_sharpness:{value:0},u_ratio:{value:1}},vertexShader:` + uniform float u_turbulenceStrength; + uniform float u_displaceSweep; + varying vec2 vUv; + varying float vSweepMask; + + float hash(vec2 p) { + return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); + } + + float noise(vec2 p) { + vec2 i = floor(p); + vec2 f = fract(p); + float a = hash(i); + float b = hash(i + vec2(1.0, 0.0)); + float c = hash(i + vec2(0.0, 1.0)); + float d = hash(i + vec2(1.0, 1.0)); + vec2 u = f * f * (3.0 - 2.0 * f); + return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; + } + + void main() { + vUv = uv; + float sweep = smoothstep(u_displaceSweep - 0.25, u_displaceSweep + 0.05, uv.x); + vSweepMask = sweep; + vec2 noiseCoord = uv * (6.0 + u_turbulenceStrength * 8.0) + vec2(u_displaceSweep * 2.0, 0.0); + float n1 = noise(noiseCoord); + float n2 = noise(noiseCoord + 3.14); + float displaceAmount = (n1 - 0.5) * u_turbulenceStrength * 1.5 * sweep; + vec3 displacedPosition = position; + displacedPosition += normal * displaceAmount; + displacedPosition.x += (n1 - 0.5) * 0.6 * u_turbulenceStrength * sweep; + displacedPosition.y += (n2 - 0.5) * 0.4 * u_turbulenceStrength * sweep; + gl_Position = projectionMatrix * modelViewMatrix * vec4(displacedPosition, 1.0); + } + `,fragmentShader:` + uniform sampler2D texture1; + uniform sampler2D texture2; + uniform float u_turbulenceStrength; + uniform float u_displaceSweep; + uniform float u_directionBlurIntensity; + uniform float u_mixFactor; + uniform float u_revealRadius; + uniform float u_sharpness; + uniform float u_ratio; + + varying vec2 vUv; + varying float vSweepMask; + + float hash(vec2 p) { + return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); + } + + float noise(vec2 p) { + vec2 i = floor(p); + vec2 f = fract(p); + float a = hash(i); + float b = hash(i + vec2(1.0, 0.0)); + float c = hash(i + vec2(0.0, 1.0)); + float d = hash(i + vec2(1.0, 1.0)); + vec2 u = f * f * (3.0 - 2.0 * f); + return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; + } + + vec2 getAspectCorrectUV(vec2 uv) { + vec2 aspectUV = uv; + if (u_ratio > 1.0) { + aspectUV.y /= u_ratio; + aspectUV.y += (1.0 - 1.0 / u_ratio) * 0.5; + } else { + aspectUV.x *= u_ratio; + aspectUV.x += (1.0 - u_ratio) * 0.5; + } + return aspectUV; + } + + vec4 sampleDirectionalBlur(sampler2D tex, vec2 uv, float intensity) { + vec4 color = texture2D(tex, clamp(uv, 0.0, 1.0)); + float total = 1.0; + if (intensity > 0.001) { + vec2 dir = vec2(1.0, 0.0); + float stepScale = intensity * 0.06; + for (int i = 1; i <= 3; i++) { + vec2 offset = dir * (float(i) * stepScale); + vec2 uvPos = clamp(uv + offset, 0.0, 1.0); + vec2 uvNeg = clamp(uv - offset, 0.0, 1.0); + color += texture2D(tex, uvPos); + color += texture2D(tex, uvNeg); + total += 2.0; + } + } + return color / total; + } + + void main() { + float sweep = vSweepMask; + vec2 noiseCoord = vUv * (6.0 + u_turbulenceStrength * 8.0) + vec2(u_displaceSweep * 2.0, 0.0); + float n1 = noise(noiseCoord); + float n2 = noise(noiseCoord + 2.31); + vec2 warp = (vec2(n1 - 0.5, n2 - 0.5)) * 0.12 * u_turbulenceStrength * sweep; + vec2 warpedUv = clamp(vUv + warp, 0.0, 1.0); + + vec4 colorA = sampleDirectionalBlur(texture1, warpedUv, u_directionBlurIntensity); + vec4 blurredB = sampleDirectionalBlur(texture2, warpedUv, u_directionBlurIntensity * (1.0 - u_sharpness)); + vec4 sharpB = texture2D(texture2, warpedUv); + vec4 colorB = mix(blurredB, sharpB, u_sharpness); + + vec2 aspectUV = getAspectCorrectUV(vUv); + float radius = length(aspectUV - vec2(0.5)); + float softness = mix(0.35, 0.02, clamp(u_sharpness, 0.0, 1.0)); + float reveal = smoothstep(u_revealRadius + softness, u_revealRadius - softness, radius); + float combinedMix = clamp(u_mixFactor + reveal * (1.0 - u_mixFactor), 0.0, 1.0); + + vec4 finalColor = mix(colorA, colorB, combinedMix); + gl_FragColor = finalColor; + } + `,transparent:false,side:THREE.DoubleSide});const mesh=new THREE.Mesh(geometry,material);mesh.name="MainTransitionPlane";mesh.position.set(0,0,0);mesh.frustumCulled=false;this.scene.add(mesh);this.sceneObjects.meshes.mainPlane=mesh;this.sceneObjects.materials.mainMaterial=material;this.sceneObjects.uniforms=material.uniforms}setupAnimations(){if(!this.sceneObjects||!this.sceneObjects.uniforms){return}const uniforms=this.sceneObjects.uniforms;const tweens=this.sceneObjects.tweens;const easing=TWEEN.Easing.Sinusoidal.InOut;const ratioState={progress:0};const ratioTween=new TWEEN.Tween(ratioState).to({progress:this.Duration},this.Duration).easing(TWEEN.Easing.Linear.None).delay(0).onUpdate(()=>{if(!this.texture1||!this.texture1.image||!this.texture1.image.width||!this.texture1.image.height){uniforms.u_ratio.value=1}else{uniforms.u_ratio.value=this.texture1.image.width/this.texture1.image.height}}).start();tweens.push(ratioTween);const turbulenceRiseState={value:0};const turbulenceRise=new TWEEN.Tween(turbulenceRiseState).to({value:.85},650).delay(50).easing(easing).onUpdate(obj=>{uniforms.u_turbulenceStrength.value=obj.value}).start();tweens.push(turbulenceRise);const turbulenceFallState={value:.85};const turbulenceFall=new TWEEN.Tween(turbulenceFallState).to({value:0},800).delay(1e3).easing(easing).onUpdate(obj=>{uniforms.u_turbulenceStrength.value=obj.value}).start();tweens.push(turbulenceFall);const sweepRiseState={value:0};const sweepRise=new TWEEN.Tween(sweepRiseState).to({value:.9},650).delay(50).easing(easing).onUpdate(obj=>{uniforms.u_displaceSweep.value=obj.value}).start();tweens.push(sweepRise);const sweepExitState={value:.9};const sweepExit=new TWEEN.Tween(sweepExitState).to({value:1},800).delay(1e3).easing(easing).onUpdate(obj=>{uniforms.u_displaceSweep.value=obj.value}).start();tweens.push(sweepExit);const blurPrepState={value:0};const blurPrep=new TWEEN.Tween(blurPrepState).to({value:.1},500).delay(50).easing(easing).onUpdate(obj=>{uniforms.u_directionBlurIntensity.value=obj.value}).start();tweens.push(blurPrep);const blurRiseState={value:.1};const blurRise=new TWEEN.Tween(blurRiseState).to({value:1},200).delay(550).easing(easing).onUpdate(obj=>{uniforms.u_directionBlurIntensity.value=obj.value}).start();tweens.push(blurRise);const blurFallState={value:1};const blurFall=new TWEEN.Tween(blurFallState).to({value:0},800).delay(1e3).easing(easing).onUpdate(obj=>{uniforms.u_directionBlurIntensity.value=obj.value}).start();tweens.push(blurFall);const revealState={value:0};const revealTween=new TWEEN.Tween(revealState).to({value:1},700).delay(500).easing(easing).onUpdate(obj=>{uniforms.u_revealRadius.value=obj.value}).start();tweens.push(revealTween);const mixIntroState={value:0};const mixIntro=new TWEEN.Tween(mixIntroState).to({value:.8},700).delay(500).easing(easing).onUpdate(obj=>{uniforms.u_mixFactor.value=obj.value}).start();tweens.push(mixIntro);const mixFinalizeState={value:.8};const mixFinalize=new TWEEN.Tween(mixFinalizeState).to({value:1},500).delay(900).easing(easing).onUpdate(obj=>{uniforms.u_mixFactor.value=obj.value}).start();tweens.push(mixFinalize);const sharpnessState={value:0};const sharpnessTween=new TWEEN.Tween(sharpnessState).to({value:1},500).delay(900).easing(easing).onUpdate(obj=>{uniforms.u_sharpness.value=obj.value}).start();tweens.push(sharpnessTween)}defaultUpdate(timestamp){if(this.sceneObjects.tweens&&this.sceneObjects.tweens.length>0){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.update==="function"){tween.update(timestamp)}})}this.update()}_predef_addTopCenterBottomStyleBorder(parent,offset,texture,cutoutAreaPosition,cutoutAreaSize){const aspectRatio=this.texture1.image.width/this.texture1.image.height;const parentInitScale=parent.scale.y;const parentPosition=parent.position;const textureWidth=texture.image.width;const textureHeight=texture.image.height;const geometry=new THREE.PlaneGeometry(10,10);const textureCenter=texture.clone();textureCenter.repeat.set(1,cutoutAreaSize.y/textureHeight);textureCenter.offset.set(0,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);const materialCenter=new THREE.MeshBasicMaterial({map:textureCenter,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialCenter.name="PlaneCenterMaterial";const planeCenter=new THREE.Mesh(geometry,materialCenter);planeCenter.name="PlaneCenter";planeCenter.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y,parentPosition.z+offset.z);planeCenter.scale.set(parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth),parentInitScale,1);this.scene.add(planeCenter);parent.attach(planeCenter);const textureTop=texture.clone();textureTop.repeat.set(1,cutoutAreaPosition.y/textureHeight);textureTop.offset.set(0,1-cutoutAreaPosition.y/textureHeight);const materialTop=new THREE.MeshBasicMaterial({map:textureTop,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialTop.name="PlaneTopMaterial";const scaleXTop=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYTop=scaleXTop*cutoutAreaPosition.y/textureWidth;const planeTop=new THREE.Mesh(geometry,materialTop);planeTop.name="PlaneTop";planeTop.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y+parentInitScale*10*.5+scaleYTop*10*.5,parentPosition.z+offset.z);planeTop.scale.set(scaleXTop,scaleYTop,1);this.scene.add(planeTop);parent.attach(planeTop);const textureBottom=texture.clone();textureBottom.repeat.set(1,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);textureBottom.offset.set(0,0);const materialBottom=new THREE.MeshBasicMaterial({map:textureBottom,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialBottom.name="PlaneBottomMaterial";const scaleXBottom=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYBottom=scaleXBottom*(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureWidth;const planeBottom=new THREE.Mesh(geometry,materialBottom);planeBottom.name="PlaneBottom";planeBottom.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y-parentInitScale*10*.5-scaleYBottom*10*.5,parentPosition.z+offset.z);planeBottom.scale.set(scaleXBottom,scaleYBottom,1);this.scene.add(planeBottom);parent.attach(planeBottom)}_predef_loadVideoTexture(path,loop,playbackRate){if(this.scene._amgScene==null){const video=document.createElement("video");video.src=path;video.muted=true;video.loop=loop;video.load();const videoTexture=new THREE.VideoTexture(video);videoTexture.currentTime=0;videoTexture.playbackRate=playbackRate;this.videoTexture=videoTexture;return videoTexture}else if(typeof this.scene._amgScene==="string"){return new THREE.Texture}else{const texture=new THREE.VideoTexture(path,loop,playbackRate);texture.load();return texture}}_predef_seekVideoTexture(time){if(this.videoTexture!=null){const videoTexture=this.videoTexture;const video=videoTexture.image;if(video.readyState>=2){const textureProperties=this.renderer.properties.get(videoTexture);var newTime=time/1e3*videoTexture.playbackRate;if(newTime<0){newTime=0}else if(newTime>video.duration){if(video.loop){newTime=newTime%video.duration}else{newTime=video.duration}}if(textureProperties.__version==videoTexture.version){videoTexture.currentTime=newTime;video.currentTime=videoTexture.currentTime}}}}_predef_seekShaderPass(time){if(!("shaderPasses"in this)||this.shaderPasses==null){return}this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="AnimSeqLoadAndCropBlendShaderPass"){if(this.texture1&&this.texture1.image){const ratio=this.texture1.image.width/this.texture1.image.height;if(typeof shaderPass.setAspectRatio==="function"){shaderPass.setAspectRatio(ratio)}}}})}}exports.ScriptScene=ScriptScene; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1 @@ +const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene,setCurrentScene,clearCurrentScene}=require("./wrapper/runtime");if(typeof window==="undefined"){const mockWindow={innerWidth:720,innerHeight:1280,devicePixelRatio:1,addEventListener:function(event,callback){},requestAnimationFrame:function(callback){},cancelAnimationFrame:function(id){},removeEventListener:function(event,callback){}};const mockDocument={createElement:function(tagName){return{style:{},setAttribute:function(){},appendChild:function(){}}},body:{appendChild:function(){}}};const getGlobalObject=function(){if(typeof global!=="undefined")return global;if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof this!=="undefined")return this;return{}};const globalObj=getGlobalObject();globalObj.window=mockWindow;globalObj.document=mockDocument;globalObj.cancelAnimationFrame=mockWindow.cancelAnimationFrame}const THREE={};const __THREE_CONSTS=require("./wrapper/Constants");THREE.FrontSide=__THREE_CONSTS.FrontSide;THREE.BackSide=__THREE_CONSTS.BackSide;THREE.DoubleSide=__THREE_CONSTS.DoubleSide;THREE.NoBlending=__THREE_CONSTS.NoBlending;THREE.NormalBlending=__THREE_CONSTS.NormalBlending;THREE.AdditiveBlending=__THREE_CONSTS.AdditiveBlending;THREE.SubtractiveBlending=__THREE_CONSTS.SubtractiveBlending;THREE.MultiplyBlending=__THREE_CONSTS.MultiplyBlending;THREE.CustomBlending=__THREE_CONSTS.CustomBlending;THREE.RepeatWrapping=__THREE_CONSTS.RepeatWrapping;THREE.ClampToEdgeWrapping=__THREE_CONSTS.ClampToEdgeWrapping;THREE.MirroredRepeatWrapping=__THREE_CONSTS.MirroredRepeatWrapping;const Vector2Wrapper=require("./wrapper/Vector2").Vector2;const Vector3Wrapper=require("./wrapper/Vector3").Vector3;const Vector4Wrapper=require("./wrapper/Vector4").Vector4;const EulerWrapper=require("./wrapper/Euler").Euler;const ColorWrapper=require("./wrapper/Color").Color;const Matrix4Wrapper=require("./wrapper/Matrix4").Matrix4;const QuaternionWrapper=require("./wrapper/Quaternion").Quaternion;const MathUtilsWrapper=require("./wrapper/MathUtils").MathUtils;const Box3Wrapper=require("./wrapper/Box3").Box3;const Box2Wrapper=require("./wrapper/Box2").Box2;const WebGLRendererWrapper=require("./wrapper/WebGLRenderer").WebGLRenderer;const Vector2=Vector2Wrapper;const Vector3=Vector3Wrapper;const Vector4=Vector4Wrapper;const Euler=EulerWrapper;const Color=ColorWrapper;const Matrix4=Matrix4Wrapper;const Quaternion=QuaternionWrapper;const MathUtils=MathUtilsWrapper;const Box3=Box3Wrapper;const Box2=Box2Wrapper;const WebGLRenderer=WebGLRendererWrapper;const BufferGeometryWrapper=require("./wrapper/BufferGeometry").BufferGeometry;const BufferAttributeWrapper=require("./wrapper/BufferAttribute").BufferAttribute;const BoxGeometryWrapper=require("./wrapper/BoxGeometry").BoxGeometry;const PlaneGeometryWrapper=require("./wrapper/PlaneGeometry").PlaneGeometry;const SphereGeometryWrapper=require("./wrapper/SphereGeometry").SphereGeometry;const CylinderGeometryWrapper=require("./wrapper/CylinderGeometry").CylinderGeometry;const CapsuleGeometryWrapper=require("./wrapper/CapsuleGeometry").CapsuleGeometry;const ShapeWrapper=require("./wrapper/Shape").Shape;const ShapeGeometryWrapper=require("./wrapper/ShapeGeometry").ShapeGeometry;const ExtrudeGeometryWrapper=require("./wrapper/ExtrudeGeometry").ExtrudeGeometry;const CurvePathWrapper=require("./wrapper/CurvePath").CurvePath;const LineCurveWrapper=require("./wrapper/CurvePath").LineCurve;const BufferGeometry=BufferGeometryWrapper;const BufferAttribute=BufferAttributeWrapper;const BoxGeometry=BoxGeometryWrapper;const PlaneGeometry=PlaneGeometryWrapper;const SphereGeometry=SphereGeometryWrapper;const CylinderGeometry=CylinderGeometryWrapper;const CapsuleGeometry=CapsuleGeometryWrapper;const Shape=ShapeWrapper;const ShapeGeometry=ShapeGeometryWrapper;const ExtrudeGeometry=ExtrudeGeometryWrapper;const CurvePath=CurvePathWrapper;const LineCurve=LineCurveWrapper;const TextureWrapper=require("./wrapper/Texture").Texture;const VideoTextureWrapper=require("./wrapper/Texture").VideoTexture;const TextureLoaderWrapper=require("./wrapper/Texture").TextureLoader;const Texture=TextureWrapper;const VideoTexture=VideoTextureWrapper;const TextureLoader=TextureLoaderWrapper;const MaterialWrapper=require("./wrapper/Material").Material;const MeshBasicMaterialWrapper=require("./wrapper/MeshBasicMaterial").MeshBasicMaterial;const ShaderMaterialWrapper=require("./wrapper/ShaderMaterial").ShaderMaterial;const Material=MaterialWrapper;const MeshBasicMaterial=MeshBasicMaterialWrapper;const ShaderMaterial=ShaderMaterialWrapper;const Object3DWrapper=require("./wrapper/Object3D").Object3D;const GroupWrapper=require("./wrapper/Group").Group;const MeshWrapper=require("./wrapper/Mesh").MeshWrapper;const PerspectiveCameraWrapper=require("./wrapper/PerspectiveCamera").PerspectiveCamera;const Object3D=Object3DWrapper;const Group=GroupWrapper;const Mesh=MeshWrapper;const PerspectiveCamera=PerspectiveCameraWrapper;class Scene{constructor(){this._objects=[];setCurrentScene(this);console.log("AMG scene created")}add(...objects){for(let i=0;iobj.update&&obj.update())}seekToTime(time){this._objects.forEach(obj=>obj.seekToTime&&obj.seekToTime(time))}dispose(){console.log("Scene: 开始清理场景资源");while(this._objects.length>0){const object=this._objects[0];this.delete(object);if(object.dispose&&typeof object.dispose==="function"){object.dispose()}if(object.geometry&&object.geometry.dispose){object.geometry.dispose()}if(object.material){if(Array.isArray(object.material)){object.material.forEach(material=>{if(material.dispose)material.dispose()})}else if(object.material.dispose){object.material.dispose()}}}if(this._amgScene){this._amgScene=null}this._objects=[];if(getCurrentScene()===this){clearCurrentScene()}console.log("Scene: 场景资源清理完成")}}class QuadraticBezierCurve3{constructor(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;return new Vector3(uu*this.p0.x+ut2*this.p1.x+tt*this.p2.x,uu*this.p0.y+ut2*this.p1.y+tt*this.p2.y,uu*this.p0.z+ut2*this.p1.z+tt*this.p2.z)}getPoints(divisions){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}}THREE.Vector2=Vector2;THREE.Vector3=Vector3;THREE.Vector4=Vector4;THREE.Euler=Euler;THREE.Color=Color;THREE.Matrix4=Matrix4;THREE.Quaternion=Quaternion;THREE.QuadraticBezierCurve3=QuadraticBezierCurve3;THREE.Box3=Box3;THREE.Box2=Box2;THREE.MathUtils=MathUtils;THREE.Scene=Scene;THREE.WebGLRenderer=WebGLRenderer;THREE.BufferGeometry=BufferGeometry;THREE.BufferAttribute=BufferAttribute;THREE.Float32BufferAttribute=BufferAttribute;THREE.BoxGeometry=BoxGeometry;THREE.PlaneGeometry=PlaneGeometry;THREE.SphereGeometry=SphereGeometry;THREE.CylinderGeometry=CylinderGeometry;THREE.CapsuleGeometry=CapsuleGeometry;THREE.Shape=Shape;THREE.ShapeGeometry=ShapeGeometry;THREE.ExtrudeGeometry=ExtrudeGeometry;THREE.CurvePath=CurvePath;THREE.LineCurve=LineCurve;THREE.Material=Material;THREE.MeshBasicMaterial=MeshBasicMaterial;THREE.ShaderMaterial=ShaderMaterial;THREE.Texture=Texture;THREE.VideoTexture=VideoTexture;THREE.TextureLoader=TextureLoader;THREE.Object3D=Group;THREE.Group=Group;THREE.Mesh=Mesh;THREE.PerspectiveCamera=PerspectiveCamera;exports.THREE=THREE;exports.getCurrentScene=getCurrentScene; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Easing=Object.freeze({Linear:Object.freeze({None:function(amount){return amount},In:function(amount){return amount},Out:function(amount){return amount},InOut:function(amount){return amount}}),Quadratic:Object.freeze({In:function(amount){return amount*amount},Out:function(amount){return amount*(2-amount)},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount}return-.5*(--amount*(amount-2)-1)}}),Cubic:Object.freeze({In:function(amount){return amount*amount*amount},Out:function(amount){return--amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount}return.5*((amount-=2)*amount*amount+2)}}),Quartic:Object.freeze({In:function(amount){return amount*amount*amount*amount},Out:function(amount){return 1- --amount*amount*amount*amount},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount}return-.5*((amount-=2)*amount*amount*amount-2)}}),Quintic:Object.freeze({In:function(amount){return amount*amount*amount*amount*amount},Out:function(amount){return--amount*amount*amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount*amount}return.5*((amount-=2)*amount*amount*amount*amount+2)}}),Sinusoidal:Object.freeze({In:function(amount){return 1-Math.sin((1-amount)*Math.PI/2)},Out:function(amount){return Math.sin(amount*Math.PI/2)},InOut:function(amount){return.5*(1-Math.sin(Math.PI*(.5-amount)))}}),Exponential:Object.freeze({In:function(amount){return amount===0?0:Math.pow(1024,amount-1)},Out:function(amount){return amount===1?1:1-Math.pow(2,-10*amount)},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}if((amount*=2)<1){return.5*Math.pow(1024,amount-1)}return.5*(-Math.pow(2,-10*(amount-1))+2)}}),Circular:Object.freeze({In:function(amount){return 1-Math.sqrt(1-amount*amount)},Out:function(amount){return Math.sqrt(1- --amount*amount)},InOut:function(amount){if((amount*=2)<1){return-.5*(Math.sqrt(1-amount*amount)-1)}return.5*(Math.sqrt(1-(amount-=2)*amount)+1)}}),Elastic:Object.freeze({In:function(amount){if(amount===0){return 0}if(amount===1){return 1}return-Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)},Out:function(amount){if(amount===0){return 0}if(amount===1){return 1}return Math.pow(2,-10*amount)*Math.sin((amount-.1)*5*Math.PI)+1},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}amount*=2;if(amount<1){return-.5*Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)}return.5*Math.pow(2,-10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)+1}}),Back:Object.freeze({In:function(amount){var s=1.70158;return amount===1?1:amount*amount*((s+1)*amount-s)},Out:function(amount){var s=1.70158;return amount===0?0:--amount*amount*((s+1)*amount+s)+1},InOut:function(amount){var s=1.70158*1.525;if((amount*=2)<1){return.5*(amount*amount*((s+1)*amount-s))}return.5*((amount-=2)*amount*((s+1)*amount+s)+2)}}),Bounce:Object.freeze({In:function(amount){return 1-Easing.Bounce.Out(1-amount)},Out:function(amount){if(amount<1/2.75){return 7.5625*amount*amount}else if(amount<2/2.75){return 7.5625*(amount-=1.5/2.75)*amount+.75}else if(amount<2.5/2.75){return 7.5625*(amount-=2.25/2.75)*amount+.9375}else{return 7.5625*(amount-=2.625/2.75)*amount+.984375}},InOut:function(amount){if(amount<.5){return Easing.Bounce.In(amount*2)*.5}return Easing.Bounce.Out(amount*2-1)*.5+.5}}),generatePow:function(power){if(power===void 0){power=4}power=power1e4?1e4:power;return{In:function(amount){return Math.pow(amount,power)},Out:function(amount){return 1-Math.pow(1-amount,power)},InOut:function(amount){if(amount<.5){return Math.pow(amount*2,power)/2}return(1-Math.pow(2-amount*2,power))/2+.5}}}});var now=function(){if(typeof process!=="undefined"&&process.hrtime){if(!now._nodeStartTime){now._nodeStartTime=process.hrtime()}var hrTime=process.hrtime(now._nodeStartTime);return hrTime[0]*1e3+hrTime[1]/1e6}if(typeof now._startTime==="undefined"){now._startTime=Date.now();now._lastReturned=0}var elapsed=Date.now()-now._startTime;if(elapsed<=now._lastReturned){now._lastReturned+=.001}else{now._lastReturned=elapsed}return now._lastReturned};function setNow(nowFunction){_nowFunc=nowFunction}var Group=function(){function Group(){var tweens=[];for(var _i=0;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){return fn(v[m],v[m-1],m-f)}return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0;var n=v.length-1;var pw=Math.pow;var bn=Interpolation.Utils.Bernstein;for(var i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0){i=Math.floor(f=m*(1+k))}return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0){return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0])}if(k>1){return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m])}return fn(v[i?i-1:0],v[i],v[m1;i--){s*=i}a[n]=s;return s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5;var v1=(p3-p1)*.5;var t2=t*t;var t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var Sequence=function(){function Sequence(){}Sequence.nextId=function(){return Sequence._nextId++};Sequence._nextId=0;return Sequence}();var mainGroup=new Group;var Tween=function(){function Tween(object,group){this._isPaused=false;this._pauseStart=0;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1e3;this._isDynamic=false;this._initialRepeat=0;this._repeat=0;this._yoyo=false;this._isPlaying=false;this._reversed=false;this._delayTime=0;this._startTime=0;this._easingFunction=Easing.Linear.None;this._interpolationFunction=Interpolation.Linear;this._chainedTweens=[];this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._id=Sequence.nextId();this._isChainStopped=false;this._propertiesAreSetUp=false;this._goToEnd=false;this._object=object;if(typeof group==="object"){this._group=group;group.add(this)}else if(group===true){this._group=mainGroup;mainGroup.add(this)}}Tween.prototype.getId=function(){return this._id};Tween.prototype.getCompleteCallback=function(){return this._onCompleteCallback};Tween.prototype.isPlaying=function(){return this._isPlaying};Tween.prototype.isPaused=function(){return this._isPaused};Tween.prototype.getDuration=function(){return this._duration};Tween.prototype.to=function(target,duration){if(duration===void 0){duration=1e3}if(this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");this._valuesEnd=target;this._propertiesAreSetUp=false;this._duration=duration<0?0:duration;return this};Tween.prototype.duration=function(duration){if(duration===void 0){duration=1e3}this._duration=duration<0?0:duration;return this};Tween.prototype.dynamic=function(dynamic){if(dynamic===void 0){dynamic=false}this._isDynamic=dynamic;return this};Tween.prototype.start=function(time,overrideStartingValues){if(time===void 0){time=now()}if(overrideStartingValues===void 0){overrideStartingValues=false}if(this._isPlaying){return this}this._repeat=this._initialRepeat;if(this._reversed){this._reversed=false;for(var property in this._valuesStartRepeat){this._swapEndStartRepeatValues(property);this._valuesStart[property]=this._valuesStartRepeat[property]}}this._isPlaying=true;this._isPaused=false;this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._isChainStopped=false;this._startTime=time;this._startTime+=this._delayTime;if(!this._propertiesAreSetUp||overrideStartingValues){this._propertiesAreSetUp=true;if(!this._isDynamic){var tmp={};for(var prop in this._valuesEnd)tmp[prop]=this._valuesEnd[prop];this._valuesEnd=tmp}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,overrideStartingValues)}return this};Tween.prototype.startFromCurrentValues=function(time){return this.start(time,true)};Tween.prototype._setupProperties=function(_object,_valuesStart,_valuesEnd,_valuesStartRepeat,overrideStartingValues){for(var property in _valuesEnd){var startValue=_object[property];var startValueIsArray=Array.isArray(startValue);var propType=startValueIsArray?"array":typeof startValue;var isInterpolationList=!startValueIsArray&&Array.isArray(_valuesEnd[property]);if(propType==="undefined"||propType==="function"){continue}if(isInterpolationList){var endValues=_valuesEnd[property];if(endValues.length===0){continue}var temp=[startValue];for(var i=0,l=endValues.length;itotalTime){return 1}var timesRepeated=Math.trunc(elapsedTime/durationAndDelay);var timeIntoCurrentRepeat=elapsedTime-timesRepeated*durationAndDelay;var portion=Math.min(timeIntoCurrentRepeat/_this._duration,1);if(portion===0&&elapsedTime===_this._duration){return 1}return portion};var elapsed=calculateElapsedPortion();var value=this._easingFunction(elapsed);this._updateProperties(this._object,this._valuesStart,this._valuesEnd,value);if(this._onUpdateCallback){this._onUpdateCallback(this._object,elapsed)}if(this._duration===0||elapsedTime>=this._duration){if(this._repeat>0){var completeCount=Math.min(Math.trunc((elapsedTime-this._duration)/durationAndDelay)+1,this._repeat);if(isFinite(this._repeat)){this._repeat-=completeCount}for(property in this._valuesStartRepeat){if(!this._yoyo&&typeof this._valuesEnd[property]==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(this._valuesEnd[property])}if(this._yoyo){this._swapEndStartRepeatValues(property)}this._valuesStart[property]=this._valuesStartRepeat[property]}if(this._yoyo){this._reversed=!this._reversed}this._startTime+=durationAndDelay*completeCount;if(this._onRepeatCallback){this._onRepeatCallback(this._object)}this._onEveryStartCallbackFired=false;return true}else{if(this._onCompleteCallback){this._onCompleteCallback(this._object)}for(var i=0,numChainedTweens=this._chainedTweens.length;ithis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681165424754429202/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1 @@ +const TWEEN=require("./tween");const customEasings=require("./customEasings").customEasings;const THREE=require("./three-amg-wrapper").THREE;const{ShaderPass}=require("./ShaderPass.js");class ScriptScene{constructor(amgScene=null,container=null){if(amgScene){this.scene=new THREE.Scene;this.scene._amgScene=amgScene}else{this.scene=new THREE.Scene}this.effect_type="transition";this.camera=null;this.renderer=null;this.scene.background=new THREE.Color(3355443);this.isAnimating=false;this.animationFrameId=null;this.sceneObjects=null;this.texture1=null;this.texture2=null;this.composer=null;this.renderPass=null;this.usePostProcessing=true;this.initCoreObjects();if(container){this.init(container)}}destroy(){this.isAnimating=false;if(this.animationFrameId!==null&&typeof cancelAnimationFrame!=="undefined"){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}if(this.renderer){this.renderer.setAnimationLoop(null);this.renderer.dispose();if(this.renderer.domElement&&this.renderer.domElement.parentNode){this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}if(this.texture1){if(typeof this.texture1.dispose==="function")this.texture1.dispose();this.texture1=null}if(this.texture2){if(typeof this.texture2.dispose==="function")this.texture2.dispose();this.texture2=null}if(this.scene){this.scene.dispose()}if(typeof window!=="undefined"){window.removeEventListener("resize",this.handleResize)}if(this.sceneObjects&&this.sceneObjects.tweens){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.stop==="function"){tween.stop()}});this.sceneObjects.tweens=[]}if(this.shaderPasses&&this.shaderPasses.length){this.shaderPasses.forEach(pass=>{if(pass&&typeof pass.dispose==="function"){try{pass.dispose()}catch(e){}}});this.shaderPasses=[]}if(this.shaderPass&&typeof this.shaderPass.dispose==="function"){try{this.shaderPass.dispose()}catch(e){}}this.shaderPass=null;if(this.composer){this.composer.dispose();this.composer=null}this.renderPass=null;this.scene=null;this.camera=null;this.renderer=null;this.sceneObjects=null}initCoreObjects(){if(typeof window!=="undefined"){if(!window.innerWidth||!window.innerHeight){window.innerWidth=600;window.innerHeight=600}window.devicePixelRatio=window.devicePixelRatio||1;if(this.scene&&this.scene._amgScene&&this.scene._amgScene.assetMgr){const inputTexture=this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");if(inputTexture&&inputTexture.width>0&&inputTexture.height>0){window.innerWidth=inputTexture.width;window.innerHeight=inputTexture.height}}}this.camera=new THREE.PerspectiveCamera(53.1,window.innerWidth/window.innerHeight,.1,1e4);this.camera.position.z=10;this.scene.add(this.camera);if(this.scene._amgScene==null){this.renderer=new THREE.WebGLRenderer({antialias:true});this.renderer.outputColorSpace=THREE.LinearSRGBColorSpace}if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight);this.renderer.setPixelRatio(window.devicePixelRatio)}this.sliders={};this.TWEEN=TWEEN;this.customEasings=customEasings;this.Duration=2e3}addShaderPass(shaderPassConfigs){if(!Array.isArray(shaderPassConfigs)){shaderPassConfigs=[shaderPassConfigs]}shaderPassConfigs.forEach(config=>{const atomicName=config.name;const className=atomicName.startsWith("Lumi")?atomicName.substring(4):atomicName;const shaderPassModule=require("../pp/Lumi"+className+"/"+className+"ShaderPass.js");const ShaderPassClass=shaderPassModule[className+"ShaderPass"];const initConfig=config&&(config.initConfig||config.config||config.params)||{};const shaderPass=new ShaderPassClass(initConfig);this.composer.addPass(shaderPass);this.shaderPasses.push(shaderPass)})}setupPostProcessing(shaderPassConfigs){const{EffectComposer}=require("./EffectComposer.js");const{RenderPass}=require("./RenderPass.js");this.composer=new EffectComposer(this.renderer);this.renderPass=new RenderPass(this.scene,this.camera);this.composer.addPass(this.renderPass);this.shaderPasses=[];this.addShaderPass(shaderPassConfigs)}initPostProcessing(){}init(container){if(this.renderer){if(container){container.appendChild(this.renderer.domElement)}else if(typeof document!=="undefined"){document.body.appendChild(this.renderer.domElement)}}if(typeof window!=="undefined"){window.addEventListener("resize",()=>this.handleResize())}}start(updateCallback){if(this.isAnimating)return;this.isAnimating=true;if(updateCallback){const animateFrame=()=>{if(!this.isAnimating)return;updateCallback();this.animationFrameId=requestAnimationFrame(animateFrame)};animateFrame()}else{this.renderer.setAnimationLoop(()=>{this.update()})}}updateScene(timestamp){if(!this.isAnimating){this.isAnimating=true}this.defaultUpdate(timestamp)}update(){if(this.usePostProcessing&&this.composer){if(this.renderPass){this.renderPass.camera=this.camera}this.composer.render()}else if(this.renderer){this.renderer.render(this.scene,this.camera)}}handleResize(){this.camera.aspect=window.innerWidth/window.innerHeight;this.camera.updateProjectionMatrix();if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight)}if(!this.isAnimating){this.update()}}loadTextures(){const textureLoader=new THREE.TextureLoader;return Promise.all([new Promise(resolve=>{this.texture1=textureLoader.load("image/Sample1.jpg",resolve);this.texture1.colorSpace=THREE.LinearSRGBColorSpace;this.texture1.wrapS=THREE.RepeatWrapping;this.texture1.wrapT=THREE.RepeatWrapping}),new Promise(resolve=>{this.texture2=textureLoader.load("image/Sample2.jpg",resolve);this.texture2.colorSpace=THREE.LinearSRGBColorSpace;this.texture2.wrapS=THREE.RepeatWrapping;this.texture2.wrapT=THREE.RepeatWrapping})])}_applyTweenInitialState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,0);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,0)}}_applyTweenFinalState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,1);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,1)}}seekToTime(time){if(!this.isAnimating){this.isAnimating=true}const clampedTime=Math.max(0,Math.min(time,this.Duration));if(this._predef_seekShaderPass){this._predef_seekShaderPass(clampedTime)}if(!this.sceneObjects.tweens||this.sceneObjects.tweens.length===0){return}let notStartTweens=[];let runningTweens=[];let finishedTweens=[];for(let i=0;i<=this.sceneObjects.tweens.length-1;i++){const tween=this.sceneObjects.tweens[i];let TweenStartTime=tween._delayTime+10;let TweenEndTime=tween._delayTime+tween._duration;if(clampedTime<=TweenStartTime){notStartTweens.push({time:TweenStartTime,tween:tween})}else if(clampedTime>=TweenEndTime){finishedTweens.push({time:TweenEndTime,tween:tween})}else{runningTweens.push(tween)}}notStartTweens.sort((a,b)=>b.time-a.time);finishedTweens.sort((a,b)=>a.time-b.time);notStartTweens.forEach(item=>{this._applyTweenInitialState(item.tween)});finishedTweens.forEach(item=>{this._applyTweenFinalState(item.tween)});runningTweens.forEach(tween=>{tween.stop();tween.start(0);tween.update(clampedTime)});this.update()}setupSliders(){}updateSliders(){}setupScene(){this.initSceneObjects();this.setupSliders();this.updateSliders();this.scene.background=new THREE.Color(0);this.createPlane();this.setupAnimation();return this.sceneObjects}initSceneObjects(){this.sceneObjects={plane:null,material:null,tweens:[]}}createPlane(){const geometry=new THREE.PlaneGeometry(10,10,100,1);const material=this.createMaterial();this.sceneObjects.material=material;const plane=new THREE.Mesh(geometry,material);plane.name="Plane";this.sceneObjects.plane=plane;this.scene.add(plane)}createMaterial(){if(!this.texture1||!this.texture2){console.error("纹理未加载!");return new THREE.MeshBasicMaterial({color:16711680})}this.texture1.minFilter=THREE.LinearFilter;this.texture1.magFilter=THREE.LinearFilter;this.texture1.wrapS=THREE.ClampToEdgeWrapping;this.texture1.wrapT=THREE.ClampToEdgeWrapping;this.texture2.minFilter=THREE.LinearFilter;this.texture2.magFilter=THREE.LinearFilter;this.texture2.wrapS=THREE.ClampToEdgeWrapping;this.texture2.wrapT=THREE.ClampToEdgeWrapping;this.shaderPass=new(require("../pp/LumiCustom/CustomShaderPass.js").CustomShaderPass);var material=this.shaderPass.material;material.uniforms.tDiffuse.value=this.texture1;material.uniforms.tDiffuse1.value=this.texture2;return material}setupAnimation(){if(!this.shaderPass){console.error("着色器传递对象未创建!");return}if(typeof this.shaderPass.setParameter!=="function"){console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`);return}const duration=this.Duration;const tweens=[];this.sceneObjects.tweens=[];const tween1=new TWEEN.Tween({intensity:0,progress:0}).to({intensity:1,progress:.5},duration*.35).delay(duration*.15).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});const tween2=new TWEEN.Tween({intensity:1,progress:.5}).to({intensity:0,progress:1},duration*.35).delay(duration*.5).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});tweens.push(tween1,tween2);tweens.forEach(tween=>tween.start());if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}defaultUpdate(timestamp){if(this.sceneObjects.tweens&&this.sceneObjects.tweens.length>0){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.update==="function"){tween.update(timestamp)}})}this.update()}_predef_addTopCenterBottomStyleBorder(parent,offset,texture,cutoutAreaPosition,cutoutAreaSize){const aspectRatio=this.texture1.image.width/this.texture1.image.height;const parentInitScale=parent.scale.y;const parentPosition=parent.position;const textureWidth=texture.image.width;const textureHeight=texture.image.height;const geometry=new THREE.PlaneGeometry(10,10);const textureCenter=texture.clone();textureCenter.repeat.set(1,cutoutAreaSize.y/textureHeight);textureCenter.offset.set(0,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);const materialCenter=new THREE.MeshBasicMaterial({map:textureCenter,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialCenter.name="PlaneCenterMaterial";const planeCenter=new THREE.Mesh(geometry,materialCenter);planeCenter.name="PlaneCenter";planeCenter.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y,parentPosition.z+offset.z);planeCenter.scale.set(parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth),parentInitScale,1);this.scene.add(planeCenter);parent.attach(planeCenter);const textureTop=texture.clone();textureTop.repeat.set(1,cutoutAreaPosition.y/textureHeight);textureTop.offset.set(0,1-cutoutAreaPosition.y/textureHeight);const materialTop=new THREE.MeshBasicMaterial({map:textureTop,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialTop.name="PlaneTopMaterial";const scaleXTop=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYTop=scaleXTop*cutoutAreaPosition.y/textureWidth;const planeTop=new THREE.Mesh(geometry,materialTop);planeTop.name="PlaneTop";planeTop.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y+parentInitScale*10*.5+scaleYTop*10*.5,parentPosition.z+offset.z);planeTop.scale.set(scaleXTop,scaleYTop,1);this.scene.add(planeTop);parent.attach(planeTop);const textureBottom=texture.clone();textureBottom.repeat.set(1,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);textureBottom.offset.set(0,0);const materialBottom=new THREE.MeshBasicMaterial({map:textureBottom,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialBottom.name="PlaneBottomMaterial";const scaleXBottom=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYBottom=scaleXBottom*(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureWidth;const planeBottom=new THREE.Mesh(geometry,materialBottom);planeBottom.name="PlaneBottom";planeBottom.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y-parentInitScale*10*.5-scaleYBottom*10*.5,parentPosition.z+offset.z);planeBottom.scale.set(scaleXBottom,scaleYBottom,1);this.scene.add(planeBottom);parent.attach(planeBottom)}_predef_loadVideoTexture(path,loop,playbackRate){if(this.scene._amgScene==null){const video=document.createElement("video");video.src=path;video.muted=true;video.loop=loop;video.load();const videoTexture=new THREE.VideoTexture(video);videoTexture.currentTime=0;videoTexture.playbackRate=playbackRate;this.videoTexture=videoTexture;return videoTexture}else if(typeof this.scene._amgScene==="string"){return new THREE.Texture}else{const texture=new THREE.VideoTexture(path,loop,playbackRate);texture.load();return texture}}_predef_seekVideoTexture(time){if(this.videoTexture!=null){const videoTexture=this.videoTexture;const video=videoTexture.image;if(video.readyState>=2){const textureProperties=this.renderer.properties.get(videoTexture);var newTime=time/1e3*videoTexture.playbackRate;if(newTime<0){newTime=0}else if(newTime>video.duration){if(video.loop){newTime=newTime%video.duration}else{newTime=video.duration}}if(textureProperties.__version==videoTexture.version){videoTexture.currentTime=newTime;video.currentTime=videoTexture.currentTime}}}}_predef_seekShaderPass(time){if(!("shaderPasses"in this)||this.shaderPasses==null){return}this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="AnimSeqLoadAndCropBlendShaderPass"){if(this.texture1&&this.texture1.image){const ratio=this.texture1.image.width/this.texture1.image.height;if(typeof shaderPass.setAspectRatio==="function"){shaderPass.setAspectRatio(ratio)}}}})}}exports.ScriptScene=ScriptScene; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1 @@ +const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene,setCurrentScene,clearCurrentScene}=require("./wrapper/runtime");if(typeof window==="undefined"){const mockWindow={innerWidth:720,innerHeight:1280,devicePixelRatio:1,addEventListener:function(event,callback){},requestAnimationFrame:function(callback){},cancelAnimationFrame:function(id){},removeEventListener:function(event,callback){}};const mockDocument={createElement:function(tagName){return{style:{},setAttribute:function(){},appendChild:function(){}}},body:{appendChild:function(){}}};const getGlobalObject=function(){if(typeof global!=="undefined")return global;if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof this!=="undefined")return this;return{}};const globalObj=getGlobalObject();globalObj.window=mockWindow;globalObj.document=mockDocument;globalObj.cancelAnimationFrame=mockWindow.cancelAnimationFrame}const THREE={};const __THREE_CONSTS=require("./wrapper/Constants");THREE.FrontSide=__THREE_CONSTS.FrontSide;THREE.BackSide=__THREE_CONSTS.BackSide;THREE.DoubleSide=__THREE_CONSTS.DoubleSide;THREE.NoBlending=__THREE_CONSTS.NoBlending;THREE.NormalBlending=__THREE_CONSTS.NormalBlending;THREE.AdditiveBlending=__THREE_CONSTS.AdditiveBlending;THREE.SubtractiveBlending=__THREE_CONSTS.SubtractiveBlending;THREE.MultiplyBlending=__THREE_CONSTS.MultiplyBlending;THREE.CustomBlending=__THREE_CONSTS.CustomBlending;THREE.RepeatWrapping=__THREE_CONSTS.RepeatWrapping;THREE.ClampToEdgeWrapping=__THREE_CONSTS.ClampToEdgeWrapping;THREE.MirroredRepeatWrapping=__THREE_CONSTS.MirroredRepeatWrapping;const Vector2Wrapper=require("./wrapper/Vector2").Vector2;const Vector3Wrapper=require("./wrapper/Vector3").Vector3;const Vector4Wrapper=require("./wrapper/Vector4").Vector4;const EulerWrapper=require("./wrapper/Euler").Euler;const ColorWrapper=require("./wrapper/Color").Color;const Matrix4Wrapper=require("./wrapper/Matrix4").Matrix4;const QuaternionWrapper=require("./wrapper/Quaternion").Quaternion;const MathUtilsWrapper=require("./wrapper/MathUtils").MathUtils;const Box3Wrapper=require("./wrapper/Box3").Box3;const Box2Wrapper=require("./wrapper/Box2").Box2;const WebGLRendererWrapper=require("./wrapper/WebGLRenderer").WebGLRenderer;const Vector2=Vector2Wrapper;const Vector3=Vector3Wrapper;const Vector4=Vector4Wrapper;const Euler=EulerWrapper;const Color=ColorWrapper;const Matrix4=Matrix4Wrapper;const Quaternion=QuaternionWrapper;const MathUtils=MathUtilsWrapper;const Box3=Box3Wrapper;const Box2=Box2Wrapper;const WebGLRenderer=WebGLRendererWrapper;const BufferGeometryWrapper=require("./wrapper/BufferGeometry").BufferGeometry;const BufferAttributeWrapper=require("./wrapper/BufferAttribute").BufferAttribute;const BoxGeometryWrapper=require("./wrapper/BoxGeometry").BoxGeometry;const PlaneGeometryWrapper=require("./wrapper/PlaneGeometry").PlaneGeometry;const SphereGeometryWrapper=require("./wrapper/SphereGeometry").SphereGeometry;const CylinderGeometryWrapper=require("./wrapper/CylinderGeometry").CylinderGeometry;const CapsuleGeometryWrapper=require("./wrapper/CapsuleGeometry").CapsuleGeometry;const ShapeWrapper=require("./wrapper/Shape").Shape;const ShapeGeometryWrapper=require("./wrapper/ShapeGeometry").ShapeGeometry;const ExtrudeGeometryWrapper=require("./wrapper/ExtrudeGeometry").ExtrudeGeometry;const CurvePathWrapper=require("./wrapper/CurvePath").CurvePath;const LineCurveWrapper=require("./wrapper/CurvePath").LineCurve;const BufferGeometry=BufferGeometryWrapper;const BufferAttribute=BufferAttributeWrapper;const BoxGeometry=BoxGeometryWrapper;const PlaneGeometry=PlaneGeometryWrapper;const SphereGeometry=SphereGeometryWrapper;const CylinderGeometry=CylinderGeometryWrapper;const CapsuleGeometry=CapsuleGeometryWrapper;const Shape=ShapeWrapper;const ShapeGeometry=ShapeGeometryWrapper;const ExtrudeGeometry=ExtrudeGeometryWrapper;const CurvePath=CurvePathWrapper;const LineCurve=LineCurveWrapper;const TextureWrapper=require("./wrapper/Texture").Texture;const VideoTextureWrapper=require("./wrapper/Texture").VideoTexture;const TextureLoaderWrapper=require("./wrapper/Texture").TextureLoader;const Texture=TextureWrapper;const VideoTexture=VideoTextureWrapper;const TextureLoader=TextureLoaderWrapper;const MaterialWrapper=require("./wrapper/Material").Material;const MeshBasicMaterialWrapper=require("./wrapper/MeshBasicMaterial").MeshBasicMaterial;const ShaderMaterialWrapper=require("./wrapper/ShaderMaterial").ShaderMaterial;const Material=MaterialWrapper;const MeshBasicMaterial=MeshBasicMaterialWrapper;const ShaderMaterial=ShaderMaterialWrapper;const Object3DWrapper=require("./wrapper/Object3D").Object3D;const GroupWrapper=require("./wrapper/Group").Group;const MeshWrapper=require("./wrapper/Mesh").MeshWrapper;const PerspectiveCameraWrapper=require("./wrapper/PerspectiveCamera").PerspectiveCamera;const Object3D=Object3DWrapper;const Group=GroupWrapper;const Mesh=MeshWrapper;const PerspectiveCamera=PerspectiveCameraWrapper;class Scene{constructor(){this._objects=[];setCurrentScene(this);console.log("AMG scene created")}add(...objects){for(let i=0;iobj.update&&obj.update())}seekToTime(time){this._objects.forEach(obj=>obj.seekToTime&&obj.seekToTime(time))}dispose(){console.log("Scene: 开始清理场景资源");while(this._objects.length>0){const object=this._objects[0];this.delete(object);if(object.dispose&&typeof object.dispose==="function"){object.dispose()}if(object.geometry&&object.geometry.dispose){object.geometry.dispose()}if(object.material){if(Array.isArray(object.material)){object.material.forEach(material=>{if(material.dispose)material.dispose()})}else if(object.material.dispose){object.material.dispose()}}}if(this._amgScene){this._amgScene=null}this._objects=[];if(getCurrentScene()===this){clearCurrentScene()}console.log("Scene: 场景资源清理完成")}}class QuadraticBezierCurve3{constructor(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;return new Vector3(uu*this.p0.x+ut2*this.p1.x+tt*this.p2.x,uu*this.p0.y+ut2*this.p1.y+tt*this.p2.y,uu*this.p0.z+ut2*this.p1.z+tt*this.p2.z)}getPoints(divisions){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}}THREE.Vector2=Vector2;THREE.Vector3=Vector3;THREE.Vector4=Vector4;THREE.Euler=Euler;THREE.Color=Color;THREE.Matrix4=Matrix4;THREE.Quaternion=Quaternion;THREE.QuadraticBezierCurve3=QuadraticBezierCurve3;THREE.Box3=Box3;THREE.Box2=Box2;THREE.MathUtils=MathUtils;THREE.Scene=Scene;THREE.WebGLRenderer=WebGLRenderer;THREE.BufferGeometry=BufferGeometry;THREE.BufferAttribute=BufferAttribute;THREE.Float32BufferAttribute=BufferAttribute;THREE.BoxGeometry=BoxGeometry;THREE.PlaneGeometry=PlaneGeometry;THREE.SphereGeometry=SphereGeometry;THREE.CylinderGeometry=CylinderGeometry;THREE.CapsuleGeometry=CapsuleGeometry;THREE.Shape=Shape;THREE.ShapeGeometry=ShapeGeometry;THREE.ExtrudeGeometry=ExtrudeGeometry;THREE.CurvePath=CurvePath;THREE.LineCurve=LineCurve;THREE.Material=Material;THREE.MeshBasicMaterial=MeshBasicMaterial;THREE.ShaderMaterial=ShaderMaterial;THREE.Texture=Texture;THREE.VideoTexture=VideoTexture;THREE.TextureLoader=TextureLoader;THREE.Object3D=Group;THREE.Group=Group;THREE.Mesh=Mesh;THREE.PerspectiveCamera=PerspectiveCamera;exports.THREE=THREE;exports.getCurrentScene=getCurrentScene; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Easing=Object.freeze({Linear:Object.freeze({None:function(amount){return amount},In:function(amount){return amount},Out:function(amount){return amount},InOut:function(amount){return amount}}),Quadratic:Object.freeze({In:function(amount){return amount*amount},Out:function(amount){return amount*(2-amount)},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount}return-.5*(--amount*(amount-2)-1)}}),Cubic:Object.freeze({In:function(amount){return amount*amount*amount},Out:function(amount){return--amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount}return.5*((amount-=2)*amount*amount+2)}}),Quartic:Object.freeze({In:function(amount){return amount*amount*amount*amount},Out:function(amount){return 1- --amount*amount*amount*amount},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount}return-.5*((amount-=2)*amount*amount*amount-2)}}),Quintic:Object.freeze({In:function(amount){return amount*amount*amount*amount*amount},Out:function(amount){return--amount*amount*amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount*amount}return.5*((amount-=2)*amount*amount*amount*amount+2)}}),Sinusoidal:Object.freeze({In:function(amount){return 1-Math.sin((1-amount)*Math.PI/2)},Out:function(amount){return Math.sin(amount*Math.PI/2)},InOut:function(amount){return.5*(1-Math.sin(Math.PI*(.5-amount)))}}),Exponential:Object.freeze({In:function(amount){return amount===0?0:Math.pow(1024,amount-1)},Out:function(amount){return amount===1?1:1-Math.pow(2,-10*amount)},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}if((amount*=2)<1){return.5*Math.pow(1024,amount-1)}return.5*(-Math.pow(2,-10*(amount-1))+2)}}),Circular:Object.freeze({In:function(amount){return 1-Math.sqrt(1-amount*amount)},Out:function(amount){return Math.sqrt(1- --amount*amount)},InOut:function(amount){if((amount*=2)<1){return-.5*(Math.sqrt(1-amount*amount)-1)}return.5*(Math.sqrt(1-(amount-=2)*amount)+1)}}),Elastic:Object.freeze({In:function(amount){if(amount===0){return 0}if(amount===1){return 1}return-Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)},Out:function(amount){if(amount===0){return 0}if(amount===1){return 1}return Math.pow(2,-10*amount)*Math.sin((amount-.1)*5*Math.PI)+1},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}amount*=2;if(amount<1){return-.5*Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)}return.5*Math.pow(2,-10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)+1}}),Back:Object.freeze({In:function(amount){var s=1.70158;return amount===1?1:amount*amount*((s+1)*amount-s)},Out:function(amount){var s=1.70158;return amount===0?0:--amount*amount*((s+1)*amount+s)+1},InOut:function(amount){var s=1.70158*1.525;if((amount*=2)<1){return.5*(amount*amount*((s+1)*amount-s))}return.5*((amount-=2)*amount*((s+1)*amount+s)+2)}}),Bounce:Object.freeze({In:function(amount){return 1-Easing.Bounce.Out(1-amount)},Out:function(amount){if(amount<1/2.75){return 7.5625*amount*amount}else if(amount<2/2.75){return 7.5625*(amount-=1.5/2.75)*amount+.75}else if(amount<2.5/2.75){return 7.5625*(amount-=2.25/2.75)*amount+.9375}else{return 7.5625*(amount-=2.625/2.75)*amount+.984375}},InOut:function(amount){if(amount<.5){return Easing.Bounce.In(amount*2)*.5}return Easing.Bounce.Out(amount*2-1)*.5+.5}}),generatePow:function(power){if(power===void 0){power=4}power=power1e4?1e4:power;return{In:function(amount){return Math.pow(amount,power)},Out:function(amount){return 1-Math.pow(1-amount,power)},InOut:function(amount){if(amount<.5){return Math.pow(amount*2,power)/2}return(1-Math.pow(2-amount*2,power))/2+.5}}}});var now=function(){if(typeof process!=="undefined"&&process.hrtime){if(!now._nodeStartTime){now._nodeStartTime=process.hrtime()}var hrTime=process.hrtime(now._nodeStartTime);return hrTime[0]*1e3+hrTime[1]/1e6}if(typeof now._startTime==="undefined"){now._startTime=Date.now();now._lastReturned=0}var elapsed=Date.now()-now._startTime;if(elapsed<=now._lastReturned){now._lastReturned+=.001}else{now._lastReturned=elapsed}return now._lastReturned};function setNow(nowFunction){_nowFunc=nowFunction}var Group=function(){function Group(){var tweens=[];for(var _i=0;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){return fn(v[m],v[m-1],m-f)}return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0;var n=v.length-1;var pw=Math.pow;var bn=Interpolation.Utils.Bernstein;for(var i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0){i=Math.floor(f=m*(1+k))}return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0){return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0])}if(k>1){return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m])}return fn(v[i?i-1:0],v[i],v[m1;i--){s*=i}a[n]=s;return s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5;var v1=(p3-p1)*.5;var t2=t*t;var t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var Sequence=function(){function Sequence(){}Sequence.nextId=function(){return Sequence._nextId++};Sequence._nextId=0;return Sequence}();var mainGroup=new Group;var Tween=function(){function Tween(object,group){this._isPaused=false;this._pauseStart=0;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1e3;this._isDynamic=false;this._initialRepeat=0;this._repeat=0;this._yoyo=false;this._isPlaying=false;this._reversed=false;this._delayTime=0;this._startTime=0;this._easingFunction=Easing.Linear.None;this._interpolationFunction=Interpolation.Linear;this._chainedTweens=[];this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._id=Sequence.nextId();this._isChainStopped=false;this._propertiesAreSetUp=false;this._goToEnd=false;this._object=object;if(typeof group==="object"){this._group=group;group.add(this)}else if(group===true){this._group=mainGroup;mainGroup.add(this)}}Tween.prototype.getId=function(){return this._id};Tween.prototype.getCompleteCallback=function(){return this._onCompleteCallback};Tween.prototype.isPlaying=function(){return this._isPlaying};Tween.prototype.isPaused=function(){return this._isPaused};Tween.prototype.getDuration=function(){return this._duration};Tween.prototype.to=function(target,duration){if(duration===void 0){duration=1e3}if(this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");this._valuesEnd=target;this._propertiesAreSetUp=false;this._duration=duration<0?0:duration;return this};Tween.prototype.duration=function(duration){if(duration===void 0){duration=1e3}this._duration=duration<0?0:duration;return this};Tween.prototype.dynamic=function(dynamic){if(dynamic===void 0){dynamic=false}this._isDynamic=dynamic;return this};Tween.prototype.start=function(time,overrideStartingValues){if(time===void 0){time=now()}if(overrideStartingValues===void 0){overrideStartingValues=false}if(this._isPlaying){return this}this._repeat=this._initialRepeat;if(this._reversed){this._reversed=false;for(var property in this._valuesStartRepeat){this._swapEndStartRepeatValues(property);this._valuesStart[property]=this._valuesStartRepeat[property]}}this._isPlaying=true;this._isPaused=false;this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._isChainStopped=false;this._startTime=time;this._startTime+=this._delayTime;if(!this._propertiesAreSetUp||overrideStartingValues){this._propertiesAreSetUp=true;if(!this._isDynamic){var tmp={};for(var prop in this._valuesEnd)tmp[prop]=this._valuesEnd[prop];this._valuesEnd=tmp}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,overrideStartingValues)}return this};Tween.prototype.startFromCurrentValues=function(time){return this.start(time,true)};Tween.prototype._setupProperties=function(_object,_valuesStart,_valuesEnd,_valuesStartRepeat,overrideStartingValues){for(var property in _valuesEnd){var startValue=_object[property];var startValueIsArray=Array.isArray(startValue);var propType=startValueIsArray?"array":typeof startValue;var isInterpolationList=!startValueIsArray&&Array.isArray(_valuesEnd[property]);if(propType==="undefined"||propType==="function"){continue}if(isInterpolationList){var endValues=_valuesEnd[property];if(endValues.length===0){continue}var temp=[startValue];for(var i=0,l=endValues.length;itotalTime){return 1}var timesRepeated=Math.trunc(elapsedTime/durationAndDelay);var timeIntoCurrentRepeat=elapsedTime-timesRepeated*durationAndDelay;var portion=Math.min(timeIntoCurrentRepeat/_this._duration,1);if(portion===0&&elapsedTime===_this._duration){return 1}return portion};var elapsed=calculateElapsedPortion();var value=this._easingFunction(elapsed);this._updateProperties(this._object,this._valuesStart,this._valuesEnd,value);if(this._onUpdateCallback){this._onUpdateCallback(this._object,elapsed)}if(this._duration===0||elapsedTime>=this._duration){if(this._repeat>0){var completeCount=Math.min(Math.trunc((elapsedTime-this._duration)/durationAndDelay)+1,this._repeat);if(isFinite(this._repeat)){this._repeat-=completeCount}for(property in this._valuesStartRepeat){if(!this._yoyo&&typeof this._valuesEnd[property]==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(this._valuesEnd[property])}if(this._yoyo){this._swapEndStartRepeatValues(property)}this._valuesStart[property]=this._valuesStartRepeat[property]}if(this._yoyo){this._reversed=!this._reversed}this._startTime+=durationAndDelay*completeCount;if(this._onRepeatCallback){this._onRepeatCallback(this._object)}this._onEveryStartCallbackFired=false;return true}else{if(this._onCompleteCallback){this._onCompleteCallback(this._object)}for(var i=0,numChainedTweens=this._chainedTweens.length;ithis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681180439469509906/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x) _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/lua/BCCGlow.lua b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/lua/BCCGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6c712a949a345735f56f8a0f0f159b5bfc6a2d19 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/lua/BCCGlow.lua @@ -0,0 +1,170 @@ +local exports = exports or {} +local BCCGlow = BCCGlow or {} +BCCGlow.__index = BCCGlow +---@class BCCGlow: ScriptComponent +---@field show int [UI(Range={0, 2}, Slider)] +---@field glowChannels int [UI(Range={0, 6}, Slider)] +---@field glowThreshold double [UI(Range={0, 1}, Drag)] +---@field glowRadius double [UI(Range={0, 50}, Drag)] +---@field glowAspectRatio double [UI(Range={-1, 1}, Drag)] +---@field glowIntensity double [UI(Range={0, 3}, Drag)] +---@field delta double [UI(Range={0, 0.1}, Drag)] +--- @field step int [UI(Range={0, 10}, Slider)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay", "Darken", "Lighten", "SoftLight", "HardLight", "Over", "Hue", "Saturation", "Color"})] +---@field colorA Color [UI(NoAlpha)] +---@field colorB Color [UI(NoAlpha)] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field quality double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay", "Darken", "Lighten", "SoftLight", "HardLight", "Over", "Hue", "Saturation", "Color" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do CombineModeIndex[value] = index - 1 end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeMode = { + Transparent = 0, Reflect = 1 +} + +function BCCGlow.new(construct, ...) + local self = setmetatable({}, BCCGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.show = 2 + self.glowChannels = 0 -- 0: rgb, 1: red, 2: green, 3: blue, 4: alpha, 5: luminance, 6: brightness + self.glowThreshold = 0.5 + self.delta = 0.075 + self.step = 0; + self.glowRadius = 0 + self.glowAspectRatio = 0 + self.glowIntensity = 1 + self.colorA = Amaz.Color(0., 0., 0.) + self.colorB = Amaz.Color(1., 1., 1.) + self.combine = 'Add' + self.edgeMode = 'Reflect' + self.quality = 0.2 + + return self +end + +function BCCGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.maskCamera = self.entity:searchEntity('MaskCamera'):getComponent('Camera') + self.horzBlurCameraEntity = self.entity:searchEntity('HorzBlurCamera') + self.vertBlurCameraEntity = self.entity:searchEntity('VertBlurCamera') + self.blendCameraEntity = self.entity:searchEntity('BlendCamera') + self.blendCamera = self.blendCameraEntity:getComponent('Camera') + self.maskMat = self.entity:searchEntity('MaskPass'):getComponent('MeshRenderer').material + self.horzBlurMat = self.entity:searchEntity('HorzBlurPass'):getComponent('MeshRenderer').material + self.vertBlurMat = self.entity:searchEntity('VertBlurPass'):getComponent('MeshRenderer').material + self.blendMat = self.entity:searchEntity('BlendPass'):getComponent('MeshRenderer').material + self.horzBlurCamera = self.horzBlurCameraEntity:getComponent('Camera') + self.vertBlurCamera = self.vertBlurCameraEntity:getComponent('Camera') +end + +function BCCGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if 'combine' == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine, comp) + else + _setEffectAttr(key, value, comp) + end + +end + +function BCCGlow:onUpdate(comp, deltaTime) + self.maskMat:setTex('u_InputTexture', self.InputTex) + self.blendMat:setTex('u_InputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show ~= 0 + self.horzBlurCameraEntity.visible = isShowResult + self.vertBlurCameraEntity.visible = isShowResult + self.blendCameraEntity.visible = isShowResult + if isShowResult then + self.maskCamera.renderTexture = self.blurTex + else + self.maskCamera.renderTexture = self.OutputTex + end + + if self.glowRadius == 0 then + self.horzBlurCameraEntity.visible = false + self.vertBlurCameraEntity.visible = false + end + + -- Amaz.LOGS('tqh-log', self.maskMat:getTex('inputTexture').width .. 'x' .. self.maskMat:getTex('inputTexture').height) + + self.maskMat:setInt('u_GlowChannels', self.glowChannels) + self.maskMat:setFloat('u_Threshold', self.glowThreshold) + self.maskMat:setFloat('u_Delta', self.delta) + self.maskMat:setInt('u_Step', self.step) + + local blurWidth = self.OutputTex.width + local blurHeight = self.OutputTex.height + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowRadius * (blurSize / 360) + local radiusX = radius + local radiusY = radius + if self.glowAspectRatio > 0 then + radiusY = radius * (1.0 - self.glowAspectRatio) + elseif self.glowAspectRatio < 0 then + radiusX = radius * (1.0 - math.abs(self.glowAspectRatio)) + end + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + self.horzBlurCamera.renderTexture.width = math.floor(blurWidth) + self.horzBlurCamera.renderTexture.height = math.floor(blurHeight) + self.vertBlurCamera.renderTexture.width = math.floor(blurWidth) + self.vertBlurCamera.renderTexture.height = math.floor(blurHeight) + self.horzBlurMat:setFloat('u_Radius', radiusX) + self.vertBlurMat:setFloat('u_Radius', radiusY) + self.horzBlurMat:setFloat("u_MaxRadius", 5 + math.floor(50 * self.quality)) + self.vertBlurMat:setFloat("u_MaxRadius", 5 + math.floor(50 * self.quality)) + local sigma = radius / 2.4 + sigma = math.pow(sigma, 2) * 2.0 + self.horzBlurMat:setFloat('u_Sigma', sigma) + self.vertBlurMat:setFloat('u_Sigma', sigma) + self.horzBlurMat:setInt('u_edgeMode', EdgeMode[self.edgeMode]) + self.vertBlurMat:setInt('u_edgeMode', EdgeMode[self.edgeMode]) + + self.blendMat:setFloat('u_Intensity', self.glowIntensity) + self.blendMat:setFloat('u_Threshold', self.glowThreshold) + self.blendMat:setInt('u_GlowChannels', self.glowChannels) + self.blendMat:setVec3('u_ColorA', Amaz.Vector3f(self.colorA.r, self.colorA.g, self.colorA.b)) + self.blendMat:setVec3('u_ColorB', Amaz.Vector3f(self.colorB.r, self.colorB.g, self.colorB.b)) + self.blendMat:setInt('u_Combine', CombineModeIndex[self.combine]) + self.blendMat:setInt('u_ShowMode', self.show) + -- Amaz.LOGS('tqh-log combine: ', self.combine) +end + +exports.BCCGlow = BCCGlow +return exports diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.frag new file mode 100644 index 0000000000000000000000000000000000000000..e83bdaa6300cf8e82bca52c6ef3e3f4957d459f4 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.frag @@ -0,0 +1,111 @@ +precision highp float; +precision highp int; + +uniform float u_Delta; +uniform mediump sampler2D u_InputTexture; +uniform mediump int u_GlowChannels; +uniform float u_Threshold; + +varying vec2 uv0; + +float _f2(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +float _f1(vec3 _p0) +{ + float _99 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_99, _p0.x, step(_99, _p0.x)); +} + +float _f3(vec2 _p0) +{ + mediump vec4 _125 = texture2D(u_InputTexture, _p0); + vec4 _t4 = _125; + if (u_GlowChannels == 5) + { + vec3 param = _125.xyz; + return _f2(param); + } + else + { + if (u_GlowChannels == 6) + { + vec3 param_1 = _125.xyz; + return _f1(param_1); + } + else + { + if (u_GlowChannels == 1) + { + return _t4.x; + } + else + { + if (u_GlowChannels == 2) + { + return _t4.y; + } + else + { + if (u_GlowChannels == 3) + { + return _t4.z; + } + else + { + if (u_GlowChannels == 4) + { + return _t4.w; + } + } + } + } + } + } + return _t4.w; +} + +vec4 _f0(float _p0, float _p1) +{ + vec4 _t0 = vec4(0.0); + float _41 = clamp(_p1, u_Delta, 1.0 - u_Delta); + float _55 = smoothstep(_41 - u_Delta, _41, _p0) - smoothstep(_41, _41 + u_Delta, _p0); + _t0.x = _55; + float _64 = u_Delta / 2.0; + if (_p0 < (_41 - _64)) + { + _t0.x = 1.0; + } + _t0.y = _55 * 0.5; + if (_p0 > (_41 + _64)) + { + _t0.y = 1.0; + } + return _t0; +} + +void main() +{ + vec4 _t5 = vec4(0.0); + if (u_GlowChannels == 0) + { + vec4 _t6 = texture2D(u_InputTexture, uv0); + float _207 = u_Threshold - u_Delta; + float _210 = u_Threshold + u_Delta; + vec3 _237 = vec3(smoothstep(_207, _210, _t6.x), smoothstep(_207, _210, _t6.y), smoothstep(_207, _210, _t6.z)); + _t5.x = _237.x; + _t5.y = _237.y; + _t5.z = _237.z; + } + else + { + vec2 param = uv0; + float param_1 = _f3(param); + float param_2 = u_Threshold; + _t5 = _f0(param_1, param_2); + } + gl_FragData[0] = _t5; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.frag new file mode 100644 index 0000000000000000000000000000000000000000..665b297eaf61e20a101546248650f71e96c09349 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.frag @@ -0,0 +1,85 @@ +precision highp float; +precision highp int; + +uniform mediump int u_edgeMode; +uniform vec4 u_ScreenParams; +uniform mediump sampler2D u_InputTexture; +uniform float u_Radius; +uniform float u_MaxRadius; +uniform float u_Sigma; + +varying vec2 uv0; + +float _f2(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +vec2 _f0(float _p0, float _p1) +{ + vec2 _t0 = vec2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +vec4 _f1(float _p0) +{ + vec2 _67 = vec2(1.0) / u_ScreenParams.xy; + vec2 _76 = uv0 + (_67 * vec2(0.0, _p0)); + vec2 _t2 = _76; + vec2 _83 = uv0 - (_67 * vec2(0.0, _p0)); + vec2 _t3 = _83; + float param = _t2.y; + float param_1 = _t3.y; + vec2 _t4 = _f0(param, param_1); + return (texture2D(u_InputTexture, _76) * _t4.x) + (texture2D(u_InputTexture, _83) * _t4.y); +} + +vec4 _f3(inout vec4 _p0) +{ + vec4 _t5 = vec4(1.0); + vec4 _t6 = vec4(0.0); + float _134 = max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +void main() +{ + vec4 param = texture2D(u_InputTexture, uv0); + vec4 _238 = _f3(param); + gl_FragData[0] = _238; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.frag new file mode 100644 index 0000000000000000000000000000000000000000..c409c9309bcb40e9f27e2978ce119175fa009ade --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.frag @@ -0,0 +1,627 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_InputTexture; +uniform mediump sampler2D u_BlurTexture; +uniform mediump int u_ShowMode; +uniform float u_Intensity; +uniform mediump int u_Combine; +uniform mediump int u_GlowChannels; +uniform vec3 u_ColorB; +uniform float u_Threshold; +uniform vec3 u_ColorA; + +varying vec2 v_uv; + +vec3 _1240; + +float _f5(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +float _f4(vec3 _p0) +{ + float _203 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_203, _p0.x, step(_203, _p0.x)); +} + +float _f0(float _p0, float _p1) +{ + float _67; + if (_p0 < 0.5) + { + _67 = _p1 - (((1.0 - (2.0 * _p0)) * _p1) * (1.0 - _p1)); + } + else + { + float _86; + if (_p1 < 0.25) + { + _86 = _p1 + ((((2.0 * _p0) - 1.0) * _p1) * ((((16.0 * _p1) - 12.0) * _p1) + 3.0)); + } + else + { + _86 = _p1 + (((2.0 * _p0) - 1.0) * (sqrt(_p1) - _p1)); + } + _67 = _86; + } + return _67; +} + +vec3 _f1(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f0(param, param_1), _f0(param_2, param_3), _f0(param_4, param_5)); +} + +float _f2(float _p0, float _p1) +{ + float _151; + if (_p0 < 0.5) + { + _151 = (2.0 * _p0) * _p1; + } + else + { + _151 = 1.0 - ((2.0 * (1.0 - _p0)) * (1.0 - _p1)); + } + return _151; +} + +vec3 _f3(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f2(param, param_1), _f2(param_2, param_3), _f2(param_4, param_5)); +} + +float _f8(vec3 _p0) +{ + return max(_p0.x, max(_p0.y, _p0.z)) - min(_p0.x, min(_p0.y, _p0.z)); +} + +vec3 _f7(inout vec3 _p0, float _p1) +{ + if (_p0.z > _p0.x) + { + _p0.y = ((_p0.y - _p0.x) * _p1) / (_p0.z - _p0.x); + _p0.z = _p1; + } + else + { + _p0.y = 0.0; + _p0.z = 0.0; + } + _p0.x = 0.0; + return _p0; +} + +vec3 _f9(inout vec3 _p0, float _p1) +{ + bool _343 = _p0.x <= _p0.y; + bool _351; + if (_343) + { + _351 = _p0.x <= _p0.z; + } + else + { + _351 = _343; + } + if (_351) + { + if (_p0.y <= _p0.z) + { + vec3 param = _p0; + float param_1 = _p1; + vec3 _365 = _f7(param, param_1); + _p0 = _365; + } + else + { + vec3 param_2 = _p0.xzy; + float param_3 = _p1; + vec3 _372 = _f7(param_2, param_3); + _p0 = vec3(_372.x, _372.z, _372.y); + } + } + else + { + bool _380 = _p0.y <= _p0.x; + bool _388; + if (_380) + { + _388 = _p0.y <= _p0.z; + } + else + { + _388 = _380; + } + if (_388) + { + if (_p0.x <= _p0.z) + { + vec3 param_4 = _p0.yxz; + float param_5 = _p1; + vec3 _403 = _f7(param_4, param_5); + _p0 = vec3(_403.y, _403.x, _403.z); + } + else + { + vec3 param_6 = _p0.yzx; + float param_7 = _p1; + vec3 _412 = _f7(param_6, param_7); + _p0 = vec3(_412.z, _412.x, _412.y); + } + } + else + { + if (_p0.x <= _p0.y) + { + vec3 param_8 = _p0.zxy; + float param_9 = _p1; + vec3 _428 = _f7(param_8, param_9); + _p0 = vec3(_428.y, _428.z, _428.x); + } + else + { + vec3 param_10 = _p0.zyx; + float param_11 = _p1; + vec3 _437 = _f7(param_10, param_11); + _p0 = vec3(_437.z, _437.y, _437.x); + } + } + } + return _p0; +} + +vec3 _f6(inout vec3 _p0, inout float _p1) +{ + vec3 param = _p0; + _p0 += vec3(_p1 - _f5(param)); + vec3 param_1 = _p0; + _p1 = _f5(param_1); + float _243 = min(_p0.x, min(_p0.y, _p0.z)); + float _246 = _p0.x; + float _248 = _p0.y; + float _250 = _p0.z; + float _252 = max(_246, max(_248, _250)); + if (_243 < 0.0) + { + _p0 = mix(vec3(_p1, _p1, _p1), _p0, vec3(_p1 / (_p1 - _243))); + } + if (_252 > 1.0) + { + _p0 = mix(vec3(_p1, _p1, _p1), _p0, vec3((1.0 - _p1) / (_252 - _p1))); + } + return _p0; +} + +vec3 _f10(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + float param_2 = _f8(param); + vec3 _449 = _f9(param_1, param_2); + vec3 param_3 = _p1; + vec3 param_4 = _449; + float param_5 = _f5(param_3); + vec3 _455 = _f6(param_4, param_5); + return _455; +} + +vec3 _f11(vec3 _p0, vec3 _p1) +{ + vec3 param = _p0; + vec3 param_1 = _p1; + float param_2 = _f8(param); + vec3 _464 = _f9(param_1, param_2); + vec3 param_3 = _p1; + vec3 param_4 = _464; + float param_5 = _f5(param_3); + vec3 _470 = _f6(param_4, param_5); + return _470; +} + +vec3 _f12(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + float param_2 = _f5(param); + vec3 _479 = _f6(param_1, param_2); + return _479; +} + +void main() +{ + mediump vec4 _494 = texture2D(u_InputTexture, v_uv); + vec4 _t4 = _494; + mediump vec4 _499 = texture2D(u_BlurTexture, v_uv); + vec4 _t5 = _499; + float _504 = (_t5.y * 2.0) - 1.0; + float _511 = (1.0 - abs(_504)) * _t5.y; + float _517 = step(_504, 0.0) * (0.5 - _511); + if (u_ShowMode == 1) + { + gl_FragData[0] = _499 * u_Intensity; + if (u_Combine == 2) + { + gl_FragData[0] = _499.xxxx * u_Intensity; + } + else + { + if (u_GlowChannels != 0) + { + gl_FragData[0] = vec4(vec3(_511) * u_Intensity, 1.0); + } + } + return; + } + vec4 _t9 = _499; + bool _562 = u_GlowChannels != 0; + if (_562) + { + if (u_Combine == 2) + { + _t9 = _499.xxxx; + } + else + { + _t9 = vec4(_511); + } + vec4 _577 = _t9; + vec3 _579 = _577.xyz * u_ColorB; + _t9.x = _579.x; + _t9.y = _579.y; + _t9.z = _579.z; + } + vec4 _587 = _t9; + vec3 _589 = _587.xyz * u_Intensity; + _t9.x = _589.x; + _t9.y = _589.y; + _t9.z = _589.z; + vec4 _596 = _t9; + vec3 _600 = clamp(_596.xyz, vec3(0.0), vec3(1.0)); + _t9.x = _600.x; + _t9.y = _600.y; + _t9.z = _600.z; + float _t10 = 0.0; + if (u_GlowChannels == 1) + { + _t10 = _t4.x; + } + else + { + if (u_GlowChannels == 2) + { + _t10 = _t4.y; + } + else + { + if (u_GlowChannels == 3) + { + _t10 = _t4.z; + } + else + { + if (u_GlowChannels == 4) + { + _t10 = _t4.w; + } + else + { + if (u_GlowChannels == 5) + { + vec3 param = _494.xyz; + _t10 = _f5(param); + } + else + { + if (u_GlowChannels == 6) + { + vec3 param_1 = _494.xyz; + _t10 = _f4(param_1); + } + } + } + } + } + } + vec4 _t11 = _494; + if (u_Combine == 1) + { + vec3 _668 = _t9.xyz + _494.xyz; + _t11.x = _668.x; + _t11.y = _668.y; + _t11.z = _668.z; + } + else + { + if (u_Combine == 2) + { + vec3 _684 = _t9.xyz * _494.xyz; + _t11.x = _684.x; + _t11.y = _684.y; + _t11.z = _684.z; + } + else + { + if (u_Combine == 3) + { + vec3 _701 = abs(_t9.xyz - _494.xyz); + _t11.x = _701.x; + _t11.y = _701.y; + _t11.z = _701.z; + } + else + { + if (u_Combine == 4) + { + if (_562) + { + vec4 _718 = _t9; + vec3 _721 = _718.xyz + vec3(_517); + _t9.x = _721.x; + _t9.y = _721.y; + _t9.z = _721.z; + } + float _731; + if (_t4.x < 0.5) + { + _731 = (2.0 * _t4.x) * _t9.x; + } + else + { + _731 = 1.0 - ((2.0 * (1.0 - _t4.x)) * (1.0 - _t9.x)); + } + float _754; + if (_t4.y < 0.5) + { + _754 = (2.0 * _t4.y) * _t9.y; + } + else + { + _754 = 1.0 - ((2.0 * (1.0 - _t4.y)) * (1.0 - _t9.y)); + } + float _777; + if (_t4.z < 0.5) + { + _777 = (2.0 * _t4.z) * _t9.z; + } + else + { + _777 = 1.0 - ((2.0 * (1.0 - _t4.z)) * (1.0 - _t9.z)); + } + vec3 _797 = vec3(_731, _754, _777); + _t11.x = _797.x; + _t11.y = _797.y; + _t11.z = _797.z; + } + else + { + if (u_Combine == 5) + { + if (_562) + { + vec4 _814 = _t9; + vec3 _817 = _814.xyz + vec3(_517); + _t9.x = _817.x; + _t9.y = _817.y; + _t9.z = _817.z; + } + vec4 _824 = _t9; + vec3 _826 = _824.xyz * 2.0; + _t9.x = _826.x; + _t9.y = _826.y; + _t9.z = _826.z; + vec3 _837 = min(_t9.xyz, _494.xyz); + _t11.x = _837.x; + _t11.y = _837.y; + _t11.z = _837.z; + } + else + { + if (u_Combine == 6) + { + vec3 _853 = max(_t9.xyz, _494.xyz); + _t11.x = _853.x; + _t11.y = _853.y; + _t11.z = _853.z; + } + else + { + if (u_Combine == 7) + { + if (_562) + { + vec4 _871 = _t9; + vec3 _874 = _871.xyz + vec3(_517); + _t9.x = _874.x; + _t9.y = _874.y; + _t9.z = _874.z; + } + vec3 param_2 = _t9.xyz; + vec3 param_3 = _494.xyz; + vec3 _887 = _f1(param_2, param_3); + _t11.x = _887.x; + _t11.y = _887.y; + _t11.z = _887.z; + } + else + { + if (u_Combine == 8) + { + if (_562) + { + vec4 _905 = _t9; + vec3 _908 = _905.xyz + vec3(_517); + _t9.x = _908.x; + _t9.y = _908.y; + _t9.z = _908.z; + } + vec3 param_4 = _t9.xyz; + vec3 param_5 = _494.xyz; + vec3 _921 = _f3(param_4, param_5); + _t11.x = _921.x; + _t11.y = _921.y; + _t11.z = _921.z; + } + else + { + if (u_Combine == 9) + { + if (u_GlowChannels == 0) + { + _t11.x = _t9.xyz.x; + _t11.y = _t9.xyz.y; + _t11.z = _t9.xyz.z; + } + else + { + vec3 _951 = _494.xyz; + vec3 _974 = mix(mix(_t9.xyz, (_t9.xyz + _951) - (_t9.xyz * _951), vec3(clamp(_t9.x, 0.0, 1.0))), _951, vec3(clamp(_517 * 2.0, 0.0, 1.0))); + _t11.x = _974.x; + _t11.y = _974.y; + _t11.z = _974.z; + } + } + else + { + if (u_Combine == 10) + { + if (u_GlowChannels == 0) + { + vec3 param_6 = _t9.xyz; + vec3 param_7 = _494.xyz; + vec3 _997 = _f10(param_6, param_7); + _t11.x = _997.x; + _t11.y = _997.y; + _t11.z = _997.z; + } + else + { + vec4 _1006 = _t9; + vec3 _1009 = _1006.xyz + vec3(_517); + _t9.x = _1009.x; + _t9.y = _1009.y; + _t9.z = _1009.z; + vec3 param_8 = _t9.xyz; + vec3 _1021 = _494.xyz; + vec3 param_9 = _1021; + vec3 _1030 = mix(_f10(param_8, param_9), _1021, vec3(clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1030.x; + _t11.y = _1030.y; + _t11.z = _1030.z; + } + } + else + { + if (u_Combine == 11) + { + if (u_GlowChannels == 0) + { + vec3 param_10 = _t9.xyz; + vec3 param_11 = _494.xyz; + vec3 _1053 = _f11(param_10, param_11); + _t11.x = _1053.x; + _t11.y = _1053.y; + _t11.z = _1053.z; + } + else + { + vec4 _1062 = _t9; + vec3 _1065 = _1062.xyz + vec3(_517); + _t9.x = _1065.x; + _t9.y = _1065.y; + _t9.z = _1065.z; + vec3 param_12 = _t9.xyz; + vec3 _1077 = _494.xyz; + vec3 param_13 = _1077; + vec3 _1086 = mix(_f11(param_12, param_13), _1077, vec3(clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1086.x; + _t11.y = _1086.y; + _t11.z = _1086.z; + } + } + else + { + if (u_Combine == 12) + { + if (u_GlowChannels == 0) + { + vec3 param_14 = _t9.xyz; + vec3 param_15 = _494.xyz; + vec3 _1109 = _f12(param_14, param_15); + _t11.x = _1109.x; + _t11.y = _1109.y; + _t11.z = _1109.z; + } + else + { + vec4 _1118 = _t9; + vec3 _1121 = _1118.xyz + vec3(_517); + _t9.x = _1121.x; + _t9.y = _1121.y; + _t9.z = _1121.z; + vec3 param_16 = _t9.xyz; + vec3 _1133 = _494.xyz; + vec3 param_17 = _1133; + vec3 _1142 = mix(_f12(param_16, param_17), _1133, vec3(clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1142.x; + _t11.y = _1142.y; + _t11.z = _1142.z; + } + } + else + { + vec3 _1153 = _494.xyz; + vec3 _1160 = (_t9.xyz + _1153) - (_t9.xyz * _1153); + _t11.x = _1160.x; + _t11.y = _1160.y; + _t11.z = _1160.z; + } + } + } + } + } + } + } + } + } + } + } + } + if (_562) + { + if (_t10 > u_Threshold) + { + vec4 _1181 = _t11; + vec3 _1183 = _1181.xyz + (u_ColorA * _t10); + _t11.x = _1183.x; + _t11.y = _1183.y; + _t11.z = _1183.z; + } + if (((((((((u_Combine == 2) || (u_Combine == 4)) || (u_Combine == 5)) || (u_Combine == 7)) || (u_Combine == 8)) || (u_Combine == 9)) || (u_Combine == 10)) || (u_Combine == 11)) || (u_Combine == 12)) + { + _t11 = mix(_494, _t11, vec4(clamp(u_Intensity, 0.0, 1.0))); + } + } + vec4 _1224 = _t11; + float _1227 = _t11.w; + vec3 _1230 = clamp(_1224.xyz, vec3(0.0), vec3(_1227)); + _t11.x = _1230.x; + _t11.y = _1230.y; + _t11.z = _1230.z; + gl_FragData[0] = _t11; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.frag new file mode 100644 index 0000000000000000000000000000000000000000..d84dbf4124497cbf994ccb4da800ee6adc0b6f20 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.frag @@ -0,0 +1,85 @@ +precision highp float; +precision highp int; + +uniform mediump int u_edgeMode; +uniform vec4 u_ScreenParams; +uniform mediump sampler2D u_InputTexture; +uniform float u_Radius; +uniform float u_MaxRadius; +uniform float u_Sigma; + +varying vec2 uv0; + +float _f2(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +vec2 _f0(float _p0, float _p1) +{ + vec2 _t0 = vec2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +vec4 _f1(float _p0) +{ + vec2 _67 = vec2(1.0) / u_ScreenParams.xy; + vec2 _76 = uv0 + (_67 * vec2(_p0, 0.0)); + vec2 _t2 = _76; + vec2 _83 = uv0 - (_67 * vec2(_p0, 0.0)); + vec2 _t3 = _83; + float param = _t2.x; + float param_1 = _t3.x; + vec2 _t4 = _f0(param, param_1); + return (texture2D(u_InputTexture, _76) * _t4.x) + (texture2D(u_InputTexture, _83) * _t4.y); +} + +vec4 _f3(inout vec4 _p0) +{ + vec4 _t5 = vec4(1.0); + vec4 _t6 = vec4(0.0); + float _134 = max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +void main() +{ + vec4 param = texture2D(u_InputTexture, uv0); + vec4 _238 = _f3(param); + gl_FragData[0] = _238; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ab53c87492678668d7660caef88cf4ef43d4424 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.frag @@ -0,0 +1,131 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_Delta; + int u_GlowChannels; + float u_Threshold; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f2(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float _f1(thread const float3& _p0) +{ + float _99 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_99, _p0.x, step(_99, _p0.x)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0, texture2d u_InputTexture, sampler u_InputTextureSmplr, constant int& u_GlowChannels) +{ + float4 _125 = u_InputTexture.sample(u_InputTextureSmplr, _p0); + float4 _t4 = _125; + if (u_GlowChannels == 5) + { + float3 param = _125.xyz; + return _f2(param); + } + else + { + if (u_GlowChannels == 6) + { + float3 param_1 = _125.xyz; + return _f1(param_1); + } + else + { + if (u_GlowChannels == 1) + { + return _t4.x; + } + else + { + if (u_GlowChannels == 2) + { + return _t4.y; + } + else + { + if (u_GlowChannels == 3) + { + return _t4.z; + } + else + { + if (u_GlowChannels == 4) + { + return _t4.w; + } + } + } + } + } + } + return _t4.w; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float& _p0, thread const float& _p1, constant float& u_Delta) +{ + float4 _t0 = float4(0.0); + float _41 = fast::clamp(_p1, u_Delta, 1.0 - u_Delta); + float _55 = smoothstep(_41 - u_Delta, _41, _p0) - smoothstep(_41, _41 + u_Delta, _p0); + _t0.x = _55; + float _64 = u_Delta / 2.0; + if (_p0 < (_41 - _64)) + { + _t0.x = 1.0; + } + _t0.y = _55 * 0.5; + if (_p0 > (_41 + _64)) + { + _t0.y = 1.0; + } + return _t0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t5 = float4(0.0); + if (buffer.u_GlowChannels == 0) + { + float4 _t6 = u_InputTexture.sample(u_InputTextureSmplr, in.uv0); + float _207 = buffer.u_Threshold - buffer.u_Delta; + float _210 = buffer.u_Threshold + buffer.u_Delta; + float3 _237 = float3(smoothstep(_207, _210, _t6.x), smoothstep(_207, _210, _t6.y), smoothstep(_207, _210, _t6.z)); + _t5.x = _237.x; + _t5.y = _237.y; + _t5.z = _237.z; + } + else + { + float2 param = in.uv0; + float param_1 = _f3(param, u_InputTexture, u_InputTextureSmplr, buffer.u_GlowChannels); + float param_2 = buffer.u_Threshold; + _t5 = _f0(param_1, param_2, buffer.u_Delta); + } + out.o_fragColor = _t5; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.frag new file mode 100644 index 0000000000000000000000000000000000000000..aa2bc92a98bc84c49a2f93add690e02d303f4d00 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.frag @@ -0,0 +1,105 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_edgeMode; + float4 u_ScreenParams; + float u_Radius; + float u_MaxRadius; + float u_Sigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float2 _f0(thread const float& _p0, thread const float& _p1, constant int& u_edgeMode) +{ + float2 _t0 = float2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr) +{ + float2 _67 = float2(1.0) / u_ScreenParams.xy; + float2 _76 = uv0 + (_67 * float2(0.0, _p0)); + float2 _t2 = _76; + float2 _83 = uv0 - (_67 * float2(0.0, _p0)); + float2 _t3 = _83; + float param = _t2.y; + float param_1 = _t3.y; + float2 _t4 = _f0(param, param_1, u_edgeMode); + return (u_InputTexture.sample(u_InputTextureSmplr, _76) * _t4.x) + (u_InputTexture.sample(u_InputTextureSmplr, _83) * _t4.y); +} + +static inline __attribute__((always_inline)) +float4 _f3(thread float4& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr, constant float& u_Radius, constant float& u_MaxRadius, constant float& u_Sigma) +{ + float4 _t5 = float4(1.0); + float4 _t6 = float4(0.0); + float _134 = fast::max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8, u_edgeMode, u_ScreenParams, uv0, u_InputTexture, u_InputTextureSmplr) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = u_InputTexture.sample(u_InputTextureSmplr, in.uv0); + float4 _238 = _f3(param, buffer.u_edgeMode, buffer.u_ScreenParams, in.uv0, u_InputTexture, u_InputTextureSmplr, buffer.u_Radius, buffer.u_MaxRadius, buffer.u_Sigma); + out.o_fragColor = _238; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.frag new file mode 100644 index 0000000000000000000000000000000000000000..f65796fa60c57f3aa8f2d43e2042e5dbaa2c240b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.frag @@ -0,0 +1,655 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_ShowMode; + float u_Intensity; + int u_Combine; + int u_GlowChannels; + float3 u_ColorB; + float u_Threshold; + float3 u_ColorA; +}; + +constant float3 _1240 = {}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f5(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float _f4(thread const float3& _p0) +{ + float _203 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_203, _p0.x, step(_203, _p0.x)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _67; + if (_p0 < 0.5) + { + _67 = _p1 - (((1.0 - (2.0 * _p0)) * _p1) * (1.0 - _p1)); + } + else + { + float _86; + if (_p1 < 0.25) + { + _86 = _p1 + ((((2.0 * _p0) - 1.0) * _p1) * ((((16.0 * _p1) - 12.0) * _p1) + 3.0)); + } + else + { + _86 = _p1 + (((2.0 * _p0) - 1.0) * (sqrt(_p1) - _p1)); + } + _67 = _86; + } + return _67; +} + +static inline __attribute__((always_inline)) +float3 _f1(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f0(param, param_1), _f0(param_2, param_3), _f0(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float _151; + if (_p0 < 0.5) + { + _151 = (2.0 * _p0) * _p1; + } + else + { + _151 = 1.0 - ((2.0 * (1.0 - _p0)) * (1.0 - _p1)); + } + return _151; +} + +static inline __attribute__((always_inline)) +float3 _f3(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f2(param, param_1), _f2(param_2, param_3), _f2(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f8(thread const float3& _p0) +{ + return fast::max(_p0.x, fast::max(_p0.y, _p0.z)) - fast::min(_p0.x, fast::min(_p0.y, _p0.z)); +} + +static inline __attribute__((always_inline)) +float3 _f7(thread float3& _p0, thread const float& _p1) +{ + if (_p0.z > _p0.x) + { + _p0.y = ((_p0.y - _p0.x) * _p1) / (_p0.z - _p0.x); + _p0.z = _p1; + } + else + { + _p0.y = 0.0; + _p0.z = 0.0; + } + _p0.x = 0.0; + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f9(thread float3& _p0, thread const float& _p1) +{ + bool _343 = _p0.x <= _p0.y; + bool _351; + if (_343) + { + _351 = _p0.x <= _p0.z; + } + else + { + _351 = _343; + } + if (_351) + { + if (_p0.y <= _p0.z) + { + float3 param = _p0; + float param_1 = _p1; + float3 _365 = _f7(param, param_1); + _p0 = _365; + } + else + { + float3 param_2 = _p0.xzy; + float param_3 = _p1; + float3 _372 = _f7(param_2, param_3); + _p0 = float3(_372.x, _372.z, _372.y); + } + } + else + { + bool _380 = _p0.y <= _p0.x; + bool _388; + if (_380) + { + _388 = _p0.y <= _p0.z; + } + else + { + _388 = _380; + } + if (_388) + { + if (_p0.x <= _p0.z) + { + float3 param_4 = _p0.yxz; + float param_5 = _p1; + float3 _403 = _f7(param_4, param_5); + _p0 = float3(_403.y, _403.x, _403.z); + } + else + { + float3 param_6 = _p0.yzx; + float param_7 = _p1; + float3 _412 = _f7(param_6, param_7); + _p0 = float3(_412.z, _412.x, _412.y); + } + } + else + { + if (_p0.x <= _p0.y) + { + float3 param_8 = _p0.zxy; + float param_9 = _p1; + float3 _428 = _f7(param_8, param_9); + _p0 = float3(_428.y, _428.z, _428.x); + } + else + { + float3 param_10 = _p0.zyx; + float param_11 = _p1; + float3 _437 = _f7(param_10, param_11); + _p0 = float3(_437.z, _437.y, _437.x); + } + } + } + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f6(thread float3& _p0, thread float& _p1) +{ + float3 param = _p0; + _p0 += float3(_p1 - _f5(param)); + float3 param_1 = _p0; + _p1 = _f5(param_1); + float _243 = fast::min(_p0.x, fast::min(_p0.y, _p0.z)); + float _246 = _p0.x; + float _248 = _p0.y; + float _250 = _p0.z; + float _252 = fast::max(_246, fast::max(_248, _250)); + if (_243 < 0.0) + { + _p0 = mix(float3(_p1, _p1, _p1), _p0, float3(_p1 / (_p1 - _243))); + } + if (_252 > 1.0) + { + _p0 = mix(float3(_p1, _p1, _p1), _p0, float3((1.0 - _p1) / (_252 - _p1))); + } + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f10(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + float param_2 = _f8(param); + float3 _449 = _f9(param_1, param_2); + float3 param_3 = _p1; + float3 param_4 = _449; + float param_5 = _f5(param_3); + float3 _455 = _f6(param_4, param_5); + return _455; +} + +static inline __attribute__((always_inline)) +float3 _f11(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p0; + float3 param_1 = _p1; + float param_2 = _f8(param); + float3 _464 = _f9(param_1, param_2); + float3 param_3 = _p1; + float3 param_4 = _464; + float param_5 = _f5(param_3); + float3 _470 = _f6(param_4, param_5); + return _470; +} + +static inline __attribute__((always_inline)) +float3 _f12(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + float param_2 = _f5(param); + float3 _479 = _f6(param_1, param_2); + return _479; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], texture2d u_BlurTexture [[texture(1)]], sampler u_InputTextureSmplr [[sampler(0)]], sampler u_BlurTextureSmplr [[sampler(1)]]) +{ + main0_out out = {}; + float4 _494 = u_InputTexture.sample(u_InputTextureSmplr, in.v_uv); + float4 _t4 = _494; + float4 _499 = u_BlurTexture.sample(u_BlurTextureSmplr, in.v_uv); + float4 _t5 = _499; + float _504 = (_t5.y * 2.0) - 1.0; + float _511 = (1.0 - abs(_504)) * _t5.y; + float _517 = step(_504, 0.0) * (0.5 - _511); + if (buffer.u_ShowMode == 1) + { + out.o_fragColor = _499 * buffer.u_Intensity; + if (buffer.u_Combine == 2) + { + out.o_fragColor = _499.xxxx * buffer.u_Intensity; + } + else + { + if (buffer.u_GlowChannels != 0) + { + out.o_fragColor = float4(float3(_511) * buffer.u_Intensity, 1.0); + } + } + return out; + } + float4 _t9 = _499; + bool _562 = buffer.u_GlowChannels != 0; + if (_562) + { + if (buffer.u_Combine == 2) + { + _t9 = _499.xxxx; + } + else + { + _t9 = float4(_511); + } + float4 _577 = _t9; + float3 _579 = _577.xyz * buffer.u_ColorB; + _t9.x = _579.x; + _t9.y = _579.y; + _t9.z = _579.z; + } + float4 _587 = _t9; + float3 _589 = _587.xyz * buffer.u_Intensity; + _t9.x = _589.x; + _t9.y = _589.y; + _t9.z = _589.z; + float4 _596 = _t9; + float3 _600 = fast::clamp(_596.xyz, float3(0.0), float3(1.0)); + _t9.x = _600.x; + _t9.y = _600.y; + _t9.z = _600.z; + float _t10 = 0.0; + if (buffer.u_GlowChannels == 1) + { + _t10 = _t4.x; + } + else + { + if (buffer.u_GlowChannels == 2) + { + _t10 = _t4.y; + } + else + { + if (buffer.u_GlowChannels == 3) + { + _t10 = _t4.z; + } + else + { + if (buffer.u_GlowChannels == 4) + { + _t10 = _t4.w; + } + else + { + if (buffer.u_GlowChannels == 5) + { + float3 param = _494.xyz; + _t10 = _f5(param); + } + else + { + if (buffer.u_GlowChannels == 6) + { + float3 param_1 = _494.xyz; + _t10 = _f4(param_1); + } + } + } + } + } + } + float4 _t11 = _494; + if (buffer.u_Combine == 1) + { + float3 _668 = _t9.xyz + _494.xyz; + _t11.x = _668.x; + _t11.y = _668.y; + _t11.z = _668.z; + } + else + { + if (buffer.u_Combine == 2) + { + float3 _684 = _t9.xyz * _494.xyz; + _t11.x = _684.x; + _t11.y = _684.y; + _t11.z = _684.z; + } + else + { + if (buffer.u_Combine == 3) + { + float3 _701 = abs(_t9.xyz - _494.xyz); + _t11.x = _701.x; + _t11.y = _701.y; + _t11.z = _701.z; + } + else + { + if (buffer.u_Combine == 4) + { + if (_562) + { + float4 _718 = _t9; + float3 _721 = _718.xyz + float3(_517); + _t9.x = _721.x; + _t9.y = _721.y; + _t9.z = _721.z; + } + float _731; + if (_t4.x < 0.5) + { + _731 = (2.0 * _t4.x) * _t9.x; + } + else + { + _731 = 1.0 - ((2.0 * (1.0 - _t4.x)) * (1.0 - _t9.x)); + } + float _754; + if (_t4.y < 0.5) + { + _754 = (2.0 * _t4.y) * _t9.y; + } + else + { + _754 = 1.0 - ((2.0 * (1.0 - _t4.y)) * (1.0 - _t9.y)); + } + float _777; + if (_t4.z < 0.5) + { + _777 = (2.0 * _t4.z) * _t9.z; + } + else + { + _777 = 1.0 - ((2.0 * (1.0 - _t4.z)) * (1.0 - _t9.z)); + } + float3 _797 = float3(_731, _754, _777); + _t11.x = _797.x; + _t11.y = _797.y; + _t11.z = _797.z; + } + else + { + if (buffer.u_Combine == 5) + { + if (_562) + { + float4 _814 = _t9; + float3 _817 = _814.xyz + float3(_517); + _t9.x = _817.x; + _t9.y = _817.y; + _t9.z = _817.z; + } + float4 _824 = _t9; + float3 _826 = _824.xyz * 2.0; + _t9.x = _826.x; + _t9.y = _826.y; + _t9.z = _826.z; + float3 _837 = fast::min(_t9.xyz, _494.xyz); + _t11.x = _837.x; + _t11.y = _837.y; + _t11.z = _837.z; + } + else + { + if (buffer.u_Combine == 6) + { + float3 _853 = fast::max(_t9.xyz, _494.xyz); + _t11.x = _853.x; + _t11.y = _853.y; + _t11.z = _853.z; + } + else + { + if (buffer.u_Combine == 7) + { + if (_562) + { + float4 _871 = _t9; + float3 _874 = _871.xyz + float3(_517); + _t9.x = _874.x; + _t9.y = _874.y; + _t9.z = _874.z; + } + float3 param_2 = _t9.xyz; + float3 param_3 = _494.xyz; + float3 _887 = _f1(param_2, param_3); + _t11.x = _887.x; + _t11.y = _887.y; + _t11.z = _887.z; + } + else + { + if (buffer.u_Combine == 8) + { + if (_562) + { + float4 _905 = _t9; + float3 _908 = _905.xyz + float3(_517); + _t9.x = _908.x; + _t9.y = _908.y; + _t9.z = _908.z; + } + float3 param_4 = _t9.xyz; + float3 param_5 = _494.xyz; + float3 _921 = _f3(param_4, param_5); + _t11.x = _921.x; + _t11.y = _921.y; + _t11.z = _921.z; + } + else + { + if (buffer.u_Combine == 9) + { + if (buffer.u_GlowChannels == 0) + { + _t11.x = _t9.xyz.x; + _t11.y = _t9.xyz.y; + _t11.z = _t9.xyz.z; + } + else + { + float3 _951 = _494.xyz; + float3 _974 = mix(mix(_t9.xyz, (_t9.xyz + _951) - (_t9.xyz * _951), float3(fast::clamp(_t9.x, 0.0, 1.0))), _951, float3(fast::clamp(_517 * 2.0, 0.0, 1.0))); + _t11.x = _974.x; + _t11.y = _974.y; + _t11.z = _974.z; + } + } + else + { + if (buffer.u_Combine == 10) + { + if (buffer.u_GlowChannels == 0) + { + float3 param_6 = _t9.xyz; + float3 param_7 = _494.xyz; + float3 _997 = _f10(param_6, param_7); + _t11.x = _997.x; + _t11.y = _997.y; + _t11.z = _997.z; + } + else + { + float4 _1006 = _t9; + float3 _1009 = _1006.xyz + float3(_517); + _t9.x = _1009.x; + _t9.y = _1009.y; + _t9.z = _1009.z; + float3 param_8 = _t9.xyz; + float3 _1021 = _494.xyz; + float3 param_9 = _1021; + float3 _1030 = mix(_f10(param_8, param_9), _1021, float3(fast::clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1030.x; + _t11.y = _1030.y; + _t11.z = _1030.z; + } + } + else + { + if (buffer.u_Combine == 11) + { + if (buffer.u_GlowChannels == 0) + { + float3 param_10 = _t9.xyz; + float3 param_11 = _494.xyz; + float3 _1053 = _f11(param_10, param_11); + _t11.x = _1053.x; + _t11.y = _1053.y; + _t11.z = _1053.z; + } + else + { + float4 _1062 = _t9; + float3 _1065 = _1062.xyz + float3(_517); + _t9.x = _1065.x; + _t9.y = _1065.y; + _t9.z = _1065.z; + float3 param_12 = _t9.xyz; + float3 _1077 = _494.xyz; + float3 param_13 = _1077; + float3 _1086 = mix(_f11(param_12, param_13), _1077, float3(fast::clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1086.x; + _t11.y = _1086.y; + _t11.z = _1086.z; + } + } + else + { + if (buffer.u_Combine == 12) + { + if (buffer.u_GlowChannels == 0) + { + float3 param_14 = _t9.xyz; + float3 param_15 = _494.xyz; + float3 _1109 = _f12(param_14, param_15); + _t11.x = _1109.x; + _t11.y = _1109.y; + _t11.z = _1109.z; + } + else + { + float4 _1118 = _t9; + float3 _1121 = _1118.xyz + float3(_517); + _t9.x = _1121.x; + _t9.y = _1121.y; + _t9.z = _1121.z; + float3 param_16 = _t9.xyz; + float3 _1133 = _494.xyz; + float3 param_17 = _1133; + float3 _1142 = mix(_f12(param_16, param_17), _1133, float3(fast::clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1142.x; + _t11.y = _1142.y; + _t11.z = _1142.z; + } + } + else + { + float3 _1153 = _494.xyz; + float3 _1160 = (_t9.xyz + _1153) - (_t9.xyz * _1153); + _t11.x = _1160.x; + _t11.y = _1160.y; + _t11.z = _1160.z; + } + } + } + } + } + } + } + } + } + } + } + } + if (_562) + { + if (_t10 > buffer.u_Threshold) + { + float4 _1181 = _t11; + float3 _1183 = _1181.xyz + (buffer.u_ColorA * _t10); + _t11.x = _1183.x; + _t11.y = _1183.y; + _t11.z = _1183.z; + } + if (((((((((buffer.u_Combine == 2) || (buffer.u_Combine == 4)) || (buffer.u_Combine == 5)) || (buffer.u_Combine == 7)) || (buffer.u_Combine == 8)) || (buffer.u_Combine == 9)) || (buffer.u_Combine == 10)) || (buffer.u_Combine == 11)) || (buffer.u_Combine == 12)) + { + _t11 = mix(_494, _t11, float4(fast::clamp(buffer.u_Intensity, 0.0, 1.0))); + } + } + float4 _1224 = _t11; + float _1227 = _t11.w; + float3 _1230 = fast::clamp(_1224.xyz, float3(0.0), float3(_1227)); + _t11.x = _1230.x; + _t11.y = _1230.y; + _t11.z = _1230.z; + out.o_fragColor = _t11; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.frag new file mode 100644 index 0000000000000000000000000000000000000000..205b251012432512401c331e7f11f1f3d6fd51b0 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.frag @@ -0,0 +1,105 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_edgeMode; + float4 u_ScreenParams; + float u_Radius; + float u_MaxRadius; + float u_Sigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float2 _f0(thread const float& _p0, thread const float& _p1, constant int& u_edgeMode) +{ + float2 _t0 = float2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr) +{ + float2 _67 = float2(1.0) / u_ScreenParams.xy; + float2 _76 = uv0 + (_67 * float2(_p0, 0.0)); + float2 _t2 = _76; + float2 _83 = uv0 - (_67 * float2(_p0, 0.0)); + float2 _t3 = _83; + float param = _t2.x; + float param_1 = _t3.x; + float2 _t4 = _f0(param, param_1, u_edgeMode); + return (u_InputTexture.sample(u_InputTextureSmplr, _76) * _t4.x) + (u_InputTexture.sample(u_InputTextureSmplr, _83) * _t4.y); +} + +static inline __attribute__((always_inline)) +float4 _f3(thread float4& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr, constant float& u_Radius, constant float& u_MaxRadius, constant float& u_Sigma) +{ + float4 _t5 = float4(1.0); + float4 _t6 = float4(0.0); + float _134 = fast::max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8, u_edgeMode, u_ScreenParams, uv0, u_InputTexture, u_InputTextureSmplr) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = u_InputTexture.sample(u_InputTextureSmplr, in.uv0); + float4 _238 = _f3(param, buffer.u_edgeMode, buffer.u_ScreenParams, in.uv0, u_InputTexture, u_InputTextureSmplr, buffer.u_Radius, buffer.u_MaxRadius, buffer.u_Sigma); + out.o_fragColor = _238; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/js/customMask.js b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/js/customMask.js new file mode 100644 index 0000000000000000000000000000000000000000..a65cc4aacc571a2ffbb05204ac82c76a80408d4c --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/js/customMask.js @@ -0,0 +1,91 @@ +const Amaz = effect.Amaz; +const cv = Amaz.JSWrapCV; +const SCRIPT_NAME = 'customMask'; +/** + * System script is NOT recommended to be used anymore. + * Avoid using system script unless you really have to. + */ +class customMask { + constructor() { + this.name = SCRIPT_NAME; + this.dis = 7 + this.curTime = 0 + } + + /** onInit is called before onStart(). */ + onInit() { } + + /** onStart is called before the first onUpdate() call. */ + onStart() { + this.lua = this.entity.getComponent('ScriptComponent'); + this.cam = this.entity.searchEntity("customMaskCam"); + this.mat = this.entity.searchEntity("customMask").getComponent("MeshRenderer").material; + } + + convertContours(contours, rw, rh, limit) { + let result = new Amaz.Vec2Vector(); + L_all: + for (let i = 0; i < contours.length; ++i) { + let contour = contours[i]; + let convertedContour = new Amaz.Vec2Vector(); + Amaz.AmazingUtil.arrayBufferToPrimitiveVector(contour, convertedContour); + for (let j = 0; j < convertedContour.size(); ++j) { + let point = convertedContour.get(j); + result.pushBack(new Amaz.Vector2f(point.x * rw, point.y * rh)); + if (result.size() >= limit) + break L_all; + } + } + return result; + } + + /** onUpdate is called once every frame. */ + onUpdate(deltaTime) { + if (!this.cam.visible) + return; + + let prop = this.lua.properties + if (!prop.has("customMaskTex")) + return; + + let resource = prop.get("customMaskTex"); + let image = resource.image; + if (image == null) + image = resource.getImage(); + if (image == null) + return; + + let size = 80 + if (prop.has("maskSize")) + size = Math.min(prop.get("maskSize"), 80); + + let mat = cv.Mat(image); + cv.resize(mat, mat, [80, 80]) + cv.cvtColor(mat, mat, 0xb); + cv.threshold(mat, mat, 125, 255, 0) + let elem = cv.getStructuringElement(2, [4, 4]); + cv.erode(mat, mat, elem); + if (size < 80) + cv.resize(mat, mat, [size, size]); + let contours = new Array(); + cv.findContours(mat, contours, 2, 1); + let convertedContours = this.convertContours(contours, 1.0 / mat.cols, 1.0 / mat.rows, 500); + this.mat.setVec2Vector("u_contours", convertedContours); + this.mat.setInt("u_pointCount", convertedContours.size()); + + // Amaz.LOGE("", `maskSize: ${size}`); + // Amaz.LOGE("", `contoursPoints: ${convertedContours.size()}`); + } + + /** onLateUpdate is called once every frame after onUpdate(). */ + onLateUpdate(deltaTime) { } + + /** onEvent is called when an event arrives. */ + onEvent(event) { + } + /** onDestroy is called when this script instance is destroyed. */ + onDestroy() { } + +} + +exports.customMask = customMask; \ No newline at end of file diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/lua/LumiBokehBlur.lua b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/lua/LumiBokehBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..51b808a5d05478faab9a76f0dc1dd44a68e1b39c --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/lua/LumiBokehBlur.lua @@ -0,0 +1,302 @@ + +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false + +local exports = exports or {} +local LumiBokehBlur = LumiBokehBlur or {} +---@class LumiBokehBlur: ScriptComponent [UI(Display="The Circle Bokeh")] +---@field bokehMode string [UI(Option={"Circle", "Heart", "Polygon","Star","CustomMask"})] +---@field scale number [UI(Range={0, 80}, Drag)] +---@field scaleX number [UI(Range={0, 1}, Drag)] +---@field scaleY number [UI(Range={0, 1}, Drag)] +---@field regionIns number [UI(Range={0., 1}, Drag)] +---@field lightIns number [UI(Range={0, 6}, Drag)] +---@field darkIns number [UI(Range={0, 4}, Drag)] +---@field quality number [UI(Range={0., 1}, Drag)] +---@field lineNum int [UI(Range={3, 8}, Slider)] +---@field shapeIns number [UI(Range={0.2, 1}, Drag)] +---@field angle number [UI(Range={-360, 360}, Drag)] +---@field customMaskTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local BokehModeName = { + "Circle", "Heart", "Polygon","Star","CustomMask" +} +setmetatable(BokehModeName, {__index = function(_, _) return BokehModeName[1] end}) + + +LumiBokehBlur.__index = LumiBokehBlur +function LumiBokehBlur.new(construct, ...) + local self = setmetatable({}, LumiBokehBlur) + if construct and LumiBokehBlur.constructor then LumiBokehBlur.constructor(self, ...) end + self.bokehMode = "Circle" + self.scale = 20 + self.scaleX = 1 + self.scaleY = 1 + self.regionIns = 0.5 + self.lightIns = 1 + self.quality = 1 + self.darkIns = 0. + self.shapeIns = 1 + + -- polygon extra param + self.angle = 0 + self.lineNum = 5 + self.customMaskTex = nil + self.InputTex = nil + self.OutputTex = nil + + self.MAX_SCALE = 80 + + return self +end + +function LumiBokehBlur:setEffectAttr(key, value, comp) + if key == "bokehMode" then + value = BokehModeName[value + 1] + end + self[key] = value + comp.properties:set(key, value) +end + +function LumiBokehBlur:onStart(comp) + self.interface = comp.properties + + self.bufBlur0 = comp.entity:searchEntity("blur0Cam"):getComponent("Camera").renderTexture + self.matBlur0 = comp.entity:searchEntity("blur0"):getComponent("MeshRenderer").material + + self.bufBlur1 = comp.entity:searchEntity("blur1Cam"):getComponent("Camera").renderTexture + self.matBlur1 = comp.entity:searchEntity("blur1"):getComponent("MeshRenderer").material + + self.objCircle = comp.entity:searchEntity("circleCam") + self.matCircle = comp.entity:searchEntity("circle"):getComponent("MeshRenderer").material + + self.objPolygon = comp.entity:searchEntity("polygonCam") + self.matPolygon = comp.entity:searchEntity("polygon"):getComponent("MeshRenderer").material + + self.objStar = comp.entity:searchEntity("starCam") + self.matStar = comp.entity:searchEntity("star"):getComponent("MeshRenderer").material + + self.objHeart = comp.entity:searchEntity("heartCam") + self.matHeart = comp.entity:searchEntity("heart"):getComponent("MeshRenderer").material + + self.objMask = comp.entity:searchEntity("getminMaskTexCam") + self.matMask = comp.entity:searchEntity("getminMaskTex"):getComponent("MeshRenderer").material + + self.objCustom = comp.entity:searchEntity("customMaskCam") + self.matCustom = comp.entity:searchEntity("customMask"):getComponent("MeshRenderer").material + + self.bufMask = self.objMask:getComponent("Camera").renderTexture + self.bufBokeh = self.objCircle:getComponent("Camera").renderTexture + + self.camOutput = comp.entity:searchEntity("in2outCam"):getComponent("Camera") +end + +function LumiBokehBlur:onUpdate(comp, dt) + if not self.OutputTex then return end + self.camOutput.renderTexture = self.OutputTex + + self.canvasW = self.OutputTex.width + self.canvasH = self.OutputTex.height + self.designScale = math.min(self.canvasW, self.canvasH) / 720 + self.realSize = self.scale * self.designScale + self.canvasScale = math.min(self.mix(6, 16, self.quality) / math.max(self.realSize, 1), 1) + self.scaledCanvasW = self.canvasW * self.canvasScale + self.scaledCanvasH = self.canvasH * self.canvasScale + self.scaledSize = self.realSize * self.canvasScale + + --Amaz.LOGE("", string.format("scaledCanvasW: %.3f", self.scaledCanvasW)) + --Amaz.LOGE("", string.format("scaledCanvasH: %.3f", self.scaledCanvasH)) + --Amaz.LOGE("", string.format("realSize: %.3f", self.realSize)) + --Amaz.LOGE("", string.format("scaledSize: %.3f", self.scaledSize)) + + self.objCircle.visible = false + self.objHeart.visible = false + self.objPolygon.visible = false + self.objStar.visible = false + self.objMask.visible = false + self.objCustom.visible = false + + self:updateBlur() + + if self.bokehMode == 'Heart' then + self:updateHeart() + elseif self.bokehMode == 'Polygon' then + self:updatePolygon() + elseif self.bokehMode == 'Star' then + self:updateStar() + elseif self.bokehMode == 'CustomMask' then + self:updateCustom() + else + self:updateCircle() + end +end + +function LumiBokehBlur:updateBlur() + self.bufBlur0.width = math.ceil(self.scaledCanvasW) + self.bufBlur0.height = math.ceil(self.scaledCanvasH) + self.bufBlur1.width = math.ceil(self.scaledCanvasW) + self.bufBlur1.height = math.ceil(self.scaledCanvasH) + + self.matBlur0:setTex("u_inputTex", self.InputTex) + + local intensity = self.scale / self.MAX_SCALE + local radius = 22 * self.designScale * self.canvasScale * math.pow(intensity, 0.35) * 0.7 + local samples = math.ceil(radius) + self.matBlur0:setInt("u_samples", samples) + self.matBlur0:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matBlur1:setInt("u_samples", samples) + self.matBlur1:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matBlur1:setFloat("u_intensity", intensity) + self.matBlur1:setFloat("u_darkIns", self.darkIns) +end + +function LumiBokehBlur:updateCircle() + self.objCircle.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.80) + local samplesEdge = math.ceil(2 * math.pi * self.scaledSize / sampleScale * 1.00) + self.matCircle:setInt("u_samplesCore", samplesCore) + self.matCircle:setInt("u_samplesEdge", samplesEdge) + self.matCircle:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matCircle:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matCircle:setFloat("u_radius", self.scaledSize) + self.matCircle:setFloat("u_regionIns", self.regionIns) + self.matCircle:setFloat("u_lightIns", self.lightIns) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur.getPolygonAngle0(lineNum, angle0) + if lineNum == 3 then + return math.rad(angle0 - 90) + elseif lineNum == 4 then + return math.rad(angle0 - 90) + elseif lineNum == 5 then + return math.rad(angle0 - 90) + elseif lineNum == 6 then + return math.rad(angle0 - 90) + elseif lineNum == 7 then + return math.rad(angle0 - 90) + else + return math.rad(angle0 - 90) + end +end +function LumiBokehBlur:updatePolygon() + self.objPolygon.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.75) + local samplesEdge = math.ceil(2 * math.pi * self.scaledSize / sampleScale * 1.00) + self.matPolygon:setInt("u_samplesCore", samplesCore) + self.matPolygon:setInt("u_samplesEdge", samplesEdge) + self.matPolygon:setInt("u_lineNum", self.lineNum) + self.matPolygon:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matPolygon:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matPolygon:setFloat("u_radius", self.scaledSize) + self.matPolygon:setFloat("u_angle0", self.getPolygonAngle0(self.lineNum, self.angle)) + self.matPolygon:setFloat("u_regionIns", self.regionIns) + self.matPolygon:setFloat("u_lightIns", self.lightIns) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur.getStarAngle0(lineNum, angle0) + if lineNum == 3 then + return math.rad(angle0 + 90) + elseif lineNum == 4 then + return math.rad(angle0 + 90) + elseif lineNum == 5 then + return math.rad(angle0 + 90) + elseif lineNum == 6 then + return math.rad(angle0 + 60) + elseif lineNum == 7 then + return math.rad(angle0 + 90) + else + return math.rad(angle0 + 22.5) + end +end +function LumiBokehBlur:updateStar() + self.objStar.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.80) + local samplesEdge = math.ceil(2 * math.pi * self.scaledSize / sampleScale * 4.00) + self.matStar:setInt("u_samplesCore", samplesCore) + self.matStar:setInt("u_samplesEdge", samplesEdge) + self.matStar:setInt("u_lineNum", self.lineNum) + self.matStar:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matStar:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matStar:setFloat("u_radius", self.scaledSize) + self.matStar:setFloat("u_angle0", self.getStarAngle0(self.lineNum, self.angle)) + self.matStar:setFloat("u_regionIns", self.regionIns) + self.matStar:setFloat("u_lightIns", self.lightIns) + self.matStar:setFloat('u_shapeIns', self.shapeIns) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur:updateHeart() + self.objHeart.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.80) + local samplesEdge = self.mix(90, 360, self.quality)--math.ceil(2 * math.pi * self.scaledSize / sampleScale * 4.00) + self.matHeart:setInt("u_samplesCore", samplesCore) + self.matHeart:setInt("u_samplesEdge", samplesEdge) + self.matHeart:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matHeart:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY * 0.8)) + self.matHeart:setFloat("u_radius", self.scaledSize) + self.matHeart:setFloat("u_regionIns", self.regionIns) + self.matHeart:setFloat("u_lightIns", self.lightIns) + self.matHeart:setFloat("u_shapeIns", self.shapeIns) + self.matHeart:setFloat("u_angle0", math.rad(self.angle + 180)) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur:updateCustom() + self.objMask.visible = true + self.objCustom.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local maskSize = self.mix(self.scaledSize, self.scale, self.quality) * 2 + local maskSizeI = math.max(math.ceil(maskSize), 8) + if self.customMaskTex then + self.bufMask.width = self.MAX_SCALE * 2 + self.bufMask.height = self.MAX_SCALE * 2 + self.interface:set("maskSize", maskSizeI) + self.matMask:setTex("u_maskTex", self.customMaskTex) + end + + self.matCustom:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matCustom:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matCustom:setInt("u_samples", math.ceil(self.scaledSize * 0.7)) + self.matCustom:setFloat("u_radius", self.scaledSize) + self.matCustom:setFloat("u_regionIns", self.regionIns) + self.matCustom:setFloat("u_lightIns", self.lightIns) + self.matCustom:setFloat("u_angle0", math.rad(self.angle + 180)) + + --Amaz.LOGE("", string.format("maskSize: %d", maskSizeI)) +end + +function LumiBokehBlur.mix(a, b, t) + return a + (b - a) * t +end + +exports.LumiBokehBlur = LumiBokehBlur +return exports diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.frag new file mode 100644 index 0000000000000000000000000000000000000000..eaae12db535b03089ca797f59cb5b7e8b4f09a0d --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.frag @@ -0,0 +1,12 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_inputTex; + +varying vec2 v_uv; + +void main() +{ + gl_FragData[0] = texture2D(u_inputTex, v_uv); +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag new file mode 100644 index 0000000000000000000000000000000000000000..962259ec4436781b043ce74eab144a92e4d284df --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag @@ -0,0 +1,85 @@ +precision highp float; +precision highp int; + +uniform mediump int u_samples; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; +uniform mediump sampler2D u_noiseTex; +uniform mediump sampler2D u_filterTex; +uniform float u_intensity; +uniform float u_darkIns; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, vec2 _p2) +{ + float param = 0.0; + float param_1 = 4.0; + float _66 = _f0(param, param_1); + float _t1 = _66; + vec2 _t2 = vec2(1.0) / _p2; + vec4 _t3 = texture2D(_p0, _p1) * _66; + mediump float _83 = float(u_samples); + for (mediump int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _83) * 15.0; + float param_3 = 4.0; + float _108 = _f0(param_2, param_3); + vec2 _117 = vec2(_t2.x * float(_t5), 0.0); + _t3 = (_t3 + (texture2D(_p0, _p1 + _117) * _108)) + (texture2D(_p0, _p1 - _117) * _108); + _t1 += (_108 + _108); + } + return _t3 / vec4(_t1); +} + +vec3 _f2(vec4 _p0) +{ + return mix(vec3(0.0), _p0.xyz / vec3(_p0.w + 9.9999997473787516355514526367188e-05), vec3(step(9.9999997473787516355514526367188e-05, _p0.w))); +} + +vec3 _f3(mediump sampler2D _p0, inout vec3 _p1) +{ + _p1 *= 63.0; + vec2 _178 = vec2(floor(_p1.z), ceil(_p1.z)); + vec2 _t10 = _178; + vec2 _183 = floor(_178 * 0.125); + vec4 _216 = (vec4(_178 - (_183 * 8.0), _183).xzyw * 0.125) + vec4(((_p1.xy + vec2(0.5)) * 0.001953125).xyxy); + return mix(texture2D(_p0, _216.xy).xyz, texture2D(_p0, _216.zw).xyz, vec3(_p1.z - _t10.x)); +} + +vec4 _f4(vec4 _p0, mediump sampler2D _p1, float _p2) +{ + vec4 param = _p0; + vec3 _242 = _f2(param); + vec3 _t17 = _242; + vec3 param_1 = _242; + vec3 _246 = _f3(_p1, param_1); + vec3 _247 = _t17; + vec3 _251 = mix(_247, _246, vec3(_p2)); + _t17 = _251; + return vec4(_251, 1.0) * _p0.w; +} + +void main() +{ + vec2 param = v_uv; + vec2 param_1 = u_screenSize; + vec4 _272 = _f1(u_inputTex, param, param_1); + vec4 _t19 = _272; + vec4 param_2 = _272; + float param_3 = (0.5 * u_intensity) * u_darkIns; + vec4 _313 = _f4(param_2, u_filterTex, param_3); + _t19 = _313; + vec3 _315 = _313.xyz; + vec3 _330 = mix(_315, _315 * ((texture2D(u_noiseTex, fract(((v_uv * u_screenSize) / vec2(min(u_screenSize.x, u_screenSize.y))) * 2.0)).x * 1.0) + 0.0), vec3(((dot(_272.xyz, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)) * 0.100000001490116119384765625) * u_intensity) * u_darkIns)); + _t19.x = _330.x; + _t19.y = _330.y; + _t19.z = _330.z; + gl_FragData[0] = _t19; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.frag new file mode 100644 index 0000000000000000000000000000000000000000..26c304d1b1ab1af74132ae1bca2e92a1b8556d71 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.frag @@ -0,0 +1,95 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform float u_angle0; +uniform mediump int u_lineNum; +uniform mediump int u_samplesCore; +uniform float u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return mat2(vec2(_36, -_33), vec2(_33, _36)); +} + +vec4 _f1(vec4 _p0) +{ + vec4 _52 = _p0 * _p0; + vec4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f2(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _84 = vec2(1.0) / _p3; + vec2 _88 = _p1 * _p3; + vec4 _t10 = vec4(0.0); + vec4 _t11 = vec4(0.0); + vec4 _t12 = vec4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + vec2 _t15 = vec2(1.0, 0.0); + float param = 2.3999631404876708984375; + mat2 _t16 = _f0(param); + mediump float _111 = 6.283185482025146484375 / float(u_lineNum); + float _115 = _111 * 0.5; + float _118 = cos(_115); + for (mediump int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _139 = _t13; + float _148 = _118 / cos(mod(_139, _111) - _115); + mediump vec4 _170 = texture2D(_p0, (_88 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _148))) * _84); + vec4 param_1 = _170; + vec4 _180 = _f1(param_1) * ((u_regionIns * _148) * _148); + _t10 = max(_t10, _170 * _80); + _t11 += (_170 * _180); + _t13 += _t14; + _t12 += _180; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + mediump float _207 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _207; + _t15 = vec2(_p2, 0.0); + float param_2 = _207; + _t16 = _f0(param_2); + for (mediump int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + mediump vec4 _252 = texture2D(_p0, (_88 + ((_t15 * u_scale) * (_118 / cos(mod(_t13, _111) - _115)))) * _84); + vec4 param_3 = _252; + vec4 _256 = _f1(param_3); + _t10 = max(_t10, _252); + _t11 += (_252 * _256); + _t13 += _t14; + _t12 += _256; + _t15 = _t16 * _t15; + } + vec4 _282 = clamp(_t11 / _t12, vec4(0.0), vec4(1.0)); + return vec4(mix(_282, _t10, clamp(_282 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f2(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..fee6b6590912543f30327f03666dea9d12bf61b6 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.frag @@ -0,0 +1,75 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform mediump int u_samplesCore; +uniform vec2 u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +vec4 _f0(vec4 _p0) +{ + vec4 _29 = _p0 * _p0; + vec4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _66 = vec2(1.0) / _p3; + vec2 _70 = _p1 * _p3; + vec2 _t10 = vec2(1.0, 0.0); + mat2 _t11 = mat2(vec2(-0.737368881702423095703125, -0.675490319728851318359375), vec2(0.675490319728851318359375, -0.737368881702423095703125)); + vec4 _t12 = vec4(0.0); + vec4 _t13 = vec4(0.0); + vec4 _t14 = vec4(0.0); + for (mediump int _t15 = 0; _t15 <= u_samplesCore; _t15++) + { + mediump vec4 _130 = texture2D(_p0, (_70 + ((_t10 * u_scale) * (sqrt(float(_t15) / float(u_samplesCore)) * _p2))) * _66); + vec4 param = _130; + vec4 _136 = _f0(param) * u_regionIns; + _t12 = max(_t12, _130 * _58); + _t13 += (_130 * _136); + _t14 += _136; + _t10 = _t11 * _t10; + } + mediump float _161 = 6.283185482025146484375 / float(u_samplesEdge); + float _163 = cos(_161); + float _165 = sin(_161); + _t10 = vec2(_p2, 0.0); + _t11 = mat2(vec2(_163, -_165), vec2(_165, _163)); + for (mediump int _t22 = 0; _t22 < u_samplesEdge; _t22++) + { + mediump vec4 _196 = texture2D(_p0, (_70 + (_t10 * u_scale)) * _66); + vec4 param_1 = _196; + vec4 _200 = _f0(param_1); + _t12 = max(_t12, _196); + _t13 += (_196 * _200); + _t14 += _200; + _t10 = _t11 * _t10; + } + vec4 _223 = clamp(_t13 / _t14, vec4(0.0), vec4(1.0)); + return vec4(mix(_223, _t12, clamp(_223 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f1(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.frag new file mode 100644 index 0000000000000000000000000000000000000000..c1bf551f43d9a993f7cbbe249baded2b3095d1b1 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.frag @@ -0,0 +1,23 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_maskTex; + +varying vec2 v_uv; + +void main() +{ + float _t0 = min(texture2D(u_maskTex, v_uv).x, 99.0); + for (mediump int _t2 = -1; _t2 <= 1; _t2++) + { + for (mediump int _t3 = -1; _t3 <= 1; _t3++) + { + _t0 = min(texture2D(u_maskTex, v_uv + (vec2(float(_t2), float(_t3)) * vec2(0.014999999664723873138427734375))).x, _t0); + } + } + float _79 = _t0; + float _111 = min(texture2D(u_maskTex, v_uv + vec2(0.0, -0.02999999932944774627685546875)).x, min(texture2D(u_maskTex, v_uv + vec2(0.0, 0.02999999932944774627685546875)).x, min(texture2D(u_maskTex, v_uv + vec2(0.02999999932944774627685546875, 0.0)).x, min(texture2D(u_maskTex, v_uv + vec2(-0.02999999932944774627685546875, 0.0)).x, _79)))); + _t0 = _111; + gl_FragData[0] = vec4(_111, _111, _111, 1.0); +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.vert new file mode 100644 index 0000000000000000000000000000000000000000..7fa9659f09c8b43c42467d693d3e1b5ba52b398a --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.vert @@ -0,0 +1,11 @@ + +attribute vec3 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = vec4(a_position, 1.0); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.frag new file mode 100644 index 0000000000000000000000000000000000000000..692c6a505159d310a919fb855a1e2f1f35a25339 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.frag @@ -0,0 +1,107 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform mediump int u_samples; +uniform float u_angle0; +uniform vec2 u_scale; +uniform mediump int u_pointCount; +uniform vec2 u_contours[500]; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform mediump sampler2D u_maskTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _40 = sin(_p0); + float _43 = cos(_p0); + return mat2(vec2(_43, -_40), vec2(_40, _43)); +} + +float _f1(float _p0, float _p1, float _p2) +{ + return (_p2 - _p0) / (_p1 - _p0); +} + +vec4 _f2(vec4 _p0) +{ + vec4 _68 = _p0 * _p0; + vec4 _72 = _68 * _68; + return (((_72 * _72) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f3(mediump sampler2D _p0, mediump sampler2D _p1, vec2 _p2, float _p3, vec2 _p4) +{ + float _96 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _100 = vec2(1.0) / _p4; + vec2 _104 = _p2 * _p4; + mediump float _110 = float(u_samples); + float _114 = _p3 / _110; + vec4 _t12 = vec4(0.0); + vec4 _t13 = vec4(0.0); + vec4 _t14 = vec4(0.0); + float param = u_angle0; + mat2 _124 = _f0(param); + mediump int _128 = -u_samples; + for (mediump int _t16 = _128; _t16 <= u_samples; _t16++) + { + mediump float _140 = float(_t16); + float _143 = -_110; + float param_1 = _143; + float param_2 = _110; + float param_3 = _140; + float _149 = _f1(param_1, param_2, param_3); + for (mediump int _t19 = _128; _t19 <= u_samples; _t19++) + { + mediump float _163 = float(_t19); + float param_4 = _143; + float param_5 = _110; + float param_6 = _163; + if (0.5 > texture2D(_p1, vec2(_149, _f1(param_4, param_5, param_6))).x) + { + continue; + } + mediump vec4 _208 = texture2D(_p0, (_104 + (_124 * ((vec2(_140, _163) * u_scale) * _114))) * _100); + vec4 param_7 = _208; + vec4 _214 = _f2(param_7) * u_regionIns; + _t12 = max(_t12, _208 * _96); + _t13 += (_208 * _214); + _t14 += _214; + } + } + for (mediump int _t26 = 0; _t26 < 500; _t26++) + { + if (_t26 >= u_pointCount) + { + break; + } + mediump vec4 _281 = texture2D(_p0, (_104 + (_124 * ((((u_contours[_t26] * 2.0) - vec2(1.0)) * u_scale) * _p3))) * _100); + vec4 param_8 = _281; + vec4 _285 = _f2(param_8); + _t12 = max(_t12, _281); + _t13 += (_281 * _285); + _t14 += _285; + } + vec4 _305 = clamp(_t13 / _t14, vec4(0.0), vec4(1.0)); + return vec4(mix(_305, _t12, clamp(_305 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f3(u_inputTex, u_maskTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.frag new file mode 100644 index 0000000000000000000000000000000000000000..b4763820a533713750b1ed32c888c296f3cc222b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.frag @@ -0,0 +1,107 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform float u_angle0; +uniform mediump int u_samplesCore; +uniform vec2 u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return mat2(vec2(_36, -_33), vec2(_33, _36)); +} + +vec4 _f1(vec4 _p0) +{ + vec4 _52 = _p0 * _p0; + vec4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f2(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _89 = vec2(1.0) / _p3; + vec2 _93 = _p1 * _p3; + float param = 0.00999999977648258209228515625; + vec2 _t11 = _f0(param) * vec2(1.0, 0.0); + float param_1 = 2.3999631404876708984375; + mat2 _t12 = _f0(param_1); + float param_2 = u_angle0; + mat2 _109 = _f0(param_2); + vec4 _t14 = vec4(0.0); + vec4 _t15 = vec4(0.0); + vec4 _t16 = vec4(0.0); + mediump int _t17 = 0; + for (;;) + { + mediump float _128 = float(u_samplesCore); + mediump float _130 = _128 * 0.0500000007450580596923828125; + mediump int _131 = int(_130); + mediump int _132 = u_samplesCore - _131; + if (_t17 <= _132) + { + float _154 = abs(_t11.y * 8.659999847412109375); + float _159 = abs(_t11.x * 8.659999847412109375); + float _161 = 2.2999999523162841796875 * sqrt(_159); + mediump vec4 _219 = texture2D(_p0, (_93 + (_109 * ((_t11 * (sqrt(float(_t17) / _128) * _p2)) * vec2(u_scale.x, u_scale.y * (mix(((_154 - _161) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _159))) + 3.0, (_154 + _161) - 3.0, step(0.0, _t11.y)) / (_154 + 1.0000000133514319600180897396058e-10)))))) * _89); + vec4 param_3 = _219; + vec4 _227 = _f1(param_3) * (u_regionIns * 2.0); + _t14 = max(_t14, _219 * _80); + _t15 += (_219 * _227); + _t16 += _227; + _t11 = _t12 * _t11; + _t17++; + continue; + } + else + { + break; + } + } + mediump float _252 = 6.283185482025146484375 / float(u_samplesEdge); + float param_4 = _252 * 0.5; + _t11 = _f0(param_4) * vec2(1.0, 0.0); + float param_5 = _252; + _t12 = _f0(param_5); + for (mediump int _t29 = 0; _t29 < u_samplesEdge; _t29++) + { + float _279 = abs(_t11.y * 8.659999847412109375); + float _283 = abs(_t11.x * 8.659999847412109375); + float _285 = 2.2999999523162841796875 * sqrt(_283); + mediump vec4 _336 = texture2D(_p0, (_93 + (_109 * ((_t11 * _p2) * vec2(u_scale.x, u_scale.y * (mix(((_279 - _285) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _283))) + 3.0, (_279 + _285) - 3.0, step(0.0, _t11.y)) / (_279 + 1.0000000133514319600180897396058e-10)))))) * _89); + vec4 param_6 = _336; + vec4 _340 = _f1(param_6); + _t14 = max(_t14, _336); + _t15 += (_336 * _340); + _t16 += _340; + _t11 = _t12 * _t11; + } + vec4 _363 = clamp(_t15 / _t16, vec4(0.0), vec4(1.0)); + return vec4(mix(_363, _t14, clamp(_363 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f2(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.frag new file mode 100644 index 0000000000000000000000000000000000000000..d57c42fab585de009e4f13f31a681d064beeba2d --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.frag @@ -0,0 +1,42 @@ +precision highp float; +precision highp int; + +uniform mediump int u_samples; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, vec2 _p2) +{ + float param = 0.0; + float param_1 = 4.0; + float _48 = _f0(param, param_1); + float _t1 = _48; + vec2 _t2 = vec2(1.0) / _p2; + vec4 _t3 = texture2D(_p0, _p1) * _48; + mediump float _66 = float(u_samples); + for (mediump int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _66) * 15.0; + float param_3 = 4.0; + float _91 = _f0(param_2, param_3); + vec2 _100 = vec2(0.0, _t2.y * float(_t5)); + _t3 = (_t3 + (texture2D(_p0, _p1 + _100) * _91)) + (texture2D(_p0, _p1 - _100) * _91); + _t1 += (_91 + _91); + } + return _t3 / vec4(_t1); +} + +void main() +{ + vec2 param = v_uv; + vec2 param_1 = u_screenSize; + gl_FragData[0] = _f1(u_inputTex, param, param_1); +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.frag new file mode 100644 index 0000000000000000000000000000000000000000..a73cc69acc4b1bc491659867bb69e9fb61efd07e --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.frag @@ -0,0 +1,93 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform float u_angle0; +uniform mediump int u_lineNum; +uniform mediump int u_samplesCore; +uniform float u_shapeIns; +uniform float u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +vec4 _f0(vec4 _p0) +{ + vec4 _29 = _p0 * _p0; + vec4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _66 = vec2(1.0) / _p3; + vec2 _70 = _p1 * _p3; + vec4 _t10 = vec4(0.0); + vec4 _t11 = vec4(0.0); + vec4 _t12 = vec4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + vec2 _t15 = vec2(1.0, 0.0); + mat2 _t16 = mat2(vec2(-0.737368881702423095703125, -0.675490319728851318359375), vec2(0.675490319728851318359375, -0.737368881702423095703125)); + mediump float _101 = 6.283185482025146484375 / float(u_lineNum); + float _105 = _101 * 0.5; + float _108 = sin(_105); + for (mediump int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _129 = _t13; + float _135 = abs(mod(_129, _101) - _105); + float _149 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _135)) + sin(_135)); + mediump vec4 _171 = texture2D(_p0, (_70 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _149))) * _66); + vec4 param = _171; + vec4 _181 = _f0(param) * ((u_regionIns * _149) * _149); + _t10 = max(_t10, _171 * _58); + _t11 += (_171 * _181); + _t13 += _t14; + _t12 += _181; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + mediump float _208 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _208; + float _210 = cos(_208); + float _212 = sin(_208); + _t15 = vec2(_p2, 0.0); + _t16 = mat2(vec2(_210, -_212), vec2(_212, _210)); + for (mediump int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + float _239 = _t13; + float _245 = abs(mod(_239, _101) - _105); + float _258 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _245)) + sin(_245)); + mediump vec4 _272 = texture2D(_p0, (_70 + ((_t15 * u_scale) * _258)) * _66); + vec4 param_1 = _272; + vec4 _280 = _f0(param_1) * (_258 * _258); + _t10 = max(_t10, _272); + _t11 += (_272 * _280); + _t13 += _t14; + _t12 += _280; + _t15 = _t16 * _t15; + } + vec4 _306 = clamp(_t11 / _t12, vec4(0.0), vec4(1.0)); + return vec4(mix(_306, _t10, clamp(_306 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f1(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.frag new file mode 100644 index 0000000000000000000000000000000000000000..7251087392c68129b65a3106ea6066dff35d7415 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag new file mode 100644 index 0000000000000000000000000000000000000000..290a8760aac3d8920edd9afc55603c520f7c409e --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag @@ -0,0 +1,104 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_samples; + float2 u_screenSize; + float u_intensity; + float u_darkIns; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float2& _p2, constant int& u_samples) +{ + float param = 0.0; + float param_1 = 4.0; + float _66 = _f0(param, param_1); + float _t1 = _66; + float2 _t2 = float2(1.0) / _p2; + float4 _t3 = _p0.sample(_p0Smplr, _p1) * _66; + float _83 = float(u_samples); + for (int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _83) * 15.0; + float param_3 = 4.0; + float _108 = _f0(param_2, param_3); + float2 _117 = float2(_t2.x * float(_t5), 0.0); + _t3 = (_t3 + (_p0.sample(_p0Smplr, (_p1 + _117)) * _108)) + (_p0.sample(_p0Smplr, (_p1 - _117)) * _108); + _t1 += (_108 + _108); + } + return _t3 / float4(_t1); +} + +static inline __attribute__((always_inline)) +float3 _f2(thread const float4& _p0) +{ + return mix(float3(0.0), _p0.xyz / float3(_p0.w + 9.9999997473787516355514526367188e-05), float3(step(9.9999997473787516355514526367188e-05, _p0.w))); +} + +static inline __attribute__((always_inline)) +float3 _f3(texture2d _p0, sampler _p0Smplr, thread float3& _p1) +{ + _p1 *= 63.0; + float2 _178 = float2(floor(_p1.z), ceil(_p1.z)); + float2 _t10 = _178; + float2 _183 = floor(_178 * 0.125); + float4 _216 = (float4(_178 - (_183 * 8.0), _183).xzyw * 0.125) + float4(((_p1.xy + float2(0.5)) * 0.001953125).xyxy); + return mix(_p0.sample(_p0Smplr, _216.xy).xyz, _p0.sample(_p0Smplr, _216.zw).xyz, float3(_p1.z - _t10.x)); +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float4& _p0, texture2d _p1, sampler _p1Smplr, thread const float& _p2) +{ + float4 param = _p0; + float3 _242 = _f2(param); + float3 _t17 = _242; + float3 param_1 = _242; + float3 _246 = _f3(_p1, _p1Smplr, param_1); + float3 _247 = _t17; + float3 _251 = mix(_247, _246, float3(_p2)); + _t17 = _251; + return float4(_251, 1.0) * _p0.w; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], texture2d u_noiseTex [[texture(1)]], texture2d u_filterTex [[texture(2)]], sampler u_inputTexSmplr [[sampler(0)]], sampler u_noiseTexSmplr [[sampler(1)]], sampler u_filterTexSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float2 param = in.v_uv; + float2 param_1 = buffer.u_screenSize; + float4 _272 = _f1(u_inputTex, u_inputTexSmplr, param, param_1, buffer.u_samples); + float4 _t19 = _272; + float4 param_2 = _272; + float param_3 = (0.5 * buffer.u_intensity) * buffer.u_darkIns; + float4 _313 = _f4(param_2, u_filterTex, u_filterTexSmplr, param_3); + _t19 = _313; + float3 _315 = _313.xyz; + float3 _330 = mix(_315, _315 * ((u_noiseTex.sample(u_noiseTexSmplr, fract(((in.v_uv * buffer.u_screenSize) / float2(fast::min(buffer.u_screenSize.x, buffer.u_screenSize.y))) * 2.0)).x * 1.0) + 0.0), float3(((dot(_272.xyz, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)) * 0.100000001490116119384765625) * buffer.u_intensity) * buffer.u_darkIns)); + _t19.x = _330.x; + _t19.y = _330.y; + _t19.z = _330.z; + out.o_fragColor = _t19; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.frag new file mode 100644 index 0000000000000000000000000000000000000000..f1990f304b2527f37f4fe5e15b8d2e5edbd70ba4 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.frag @@ -0,0 +1,121 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float u_regionIns; + float u_angle0; + int u_lineNum; + int u_samplesCore; + float u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return float2x2(float2(_36, -_33), float2(_33, _36)); +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float4& _p0) +{ + float4 _52 = _p0 * _p0; + float4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant float& u_angle0, constant int& u_lineNum, constant int& u_samplesCore, constant float& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _84 = float2(1.0) / _p3; + float2 _88 = _p1 * _p3; + float4 _t10 = float4(0.0); + float4 _t11 = float4(0.0); + float4 _t12 = float4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + float2 _t15 = float2(1.0, 0.0); + float param = 2.3999631404876708984375; + float2x2 _t16 = _f0(param); + float _111 = 6.283185482025146484375 / float(u_lineNum); + float _115 = _111 * 0.5; + float _118 = cos(_115); + for (int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _139 = _t13; + float _148 = _118 / cos(mod(_139, _111) - _115); + float4 _170 = _p0.sample(_p0Smplr, ((_88 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _148))) * _84)); + float4 param_1 = _170; + float4 _180 = _f1(param_1) * ((u_regionIns * _148) * _148); + _t10 = fast::max(_t10, _170 * _80); + _t11 += (_170 * _180); + _t13 += _t14; + _t12 += _180; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + float _207 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _207; + _t15 = float2(_p2, 0.0); + float param_2 = _207; + _t16 = _f0(param_2); + for (int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + float4 _252 = _p0.sample(_p0Smplr, ((_88 + ((_t15 * u_scale) * (_118 / cos(mod(_t13, _111) - _115)))) * _84)); + float4 param_3 = _252; + float4 _256 = _f1(param_3); + _t10 = fast::max(_t10, _252); + _t11 += (_252 * _256); + _t13 += _t14; + _t12 += _256; + _t15 = _t16 * _t15; + } + float4 _282 = fast::clamp(_t11 / _t12, float4(0.0), float4(1.0)); + return float4(mix(_282, _t10, fast::clamp(_282 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f2(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_angle0, buffer.u_lineNum, buffer.u_samplesCore, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..ecfe3f96fd7aa905b719a695a5f7cdd5589f0ab5 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.frag @@ -0,0 +1,93 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_regionIns; + int u_samplesCore; + float2 u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f0(thread const float4& _p0) +{ + float4 _29 = _p0 * _p0; + float4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant int& u_samplesCore, constant float2& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _66 = float2(1.0) / _p3; + float2 _70 = _p1 * _p3; + float2 _t10 = float2(1.0, 0.0); + float2x2 _t11 = float2x2(float2(-0.737368881702423095703125, -0.675490319728851318359375), float2(0.675490319728851318359375, -0.737368881702423095703125)); + float4 _t12 = float4(0.0); + float4 _t13 = float4(0.0); + float4 _t14 = float4(0.0); + for (int _t15 = 0; _t15 <= u_samplesCore; _t15++) + { + float4 _130 = _p0.sample(_p0Smplr, ((_70 + ((_t10 * u_scale) * (sqrt(float(_t15) / float(u_samplesCore)) * _p2))) * _66)); + float4 param = _130; + float4 _136 = _f0(param) * u_regionIns; + _t12 = fast::max(_t12, _130 * _58); + _t13 += (_130 * _136); + _t14 += _136; + _t10 = _t11 * _t10; + } + float _161 = 6.283185482025146484375 / float(u_samplesEdge); + float _163 = cos(_161); + float _165 = sin(_161); + _t10 = float2(_p2, 0.0); + _t11 = float2x2(float2(_163, -_165), float2(_165, _163)); + for (int _t22 = 0; _t22 < u_samplesEdge; _t22++) + { + float4 _196 = _p0.sample(_p0Smplr, ((_70 + (_t10 * u_scale)) * _66)); + float4 param_1 = _196; + float4 _200 = _f0(param_1); + _t12 = fast::max(_t12, _196); + _t13 += (_196 * _200); + _t14 += _200; + _t10 = _t11 * _t10; + } + float4 _223 = fast::clamp(_t13 / _t14, float4(0.0), float4(1.0)); + return float4(mix(_223, _t12, fast::clamp(_223 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f1(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_samplesCore, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.frag new file mode 100644 index 0000000000000000000000000000000000000000..b8ee25330b7889fcad393af1609f5ea4f0a8aa86 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.frag @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d u_maskTex [[texture(0)]], sampler u_maskTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float _t0 = fast::min(u_maskTex.sample(u_maskTexSmplr, in.v_uv).x, 99.0); + for (int _t2 = -1; _t2 <= 1; _t2++) + { + for (int _t3 = -1; _t3 <= 1; _t3++) + { + _t0 = fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + (float2(float(_t2), float(_t3)) * float2(0.014999999664723873138427734375)))).x, _t0); + } + } + float _79 = _t0; + float _111 = fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(0.0, -0.02999999932944774627685546875))).x, fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(0.0, 0.02999999932944774627685546875))).x, fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(0.02999999932944774627685546875, 0.0))).x, fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(-0.02999999932944774627685546875, 0.0))).x, _79)))); + _t0 = _111; + out.o_fragColor = float4(_111, _111, _111, 1.0); + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.vert new file mode 100644 index 0000000000000000000000000000000000000000..5cc14a84ffd84f48e3d4f8eea81d69228b466b55 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float3 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = float4(in.a_position, 1.0); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.frag new file mode 100644 index 0000000000000000000000000000000000000000..4c74acdf4aa5346d5c4131e9504df05e5169dbaa --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.frag @@ -0,0 +1,165 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct buffer_t +{ + float u_regionIns; + int u_samples; + float u_angle0; + float2 u_scale; + int u_pointCount; + spvUnsafeArray u_contours; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _40 = sin(_p0); + float _43 = cos(_p0); + return float2x2(float2(_43, -_40), float2(_40, _43)); +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1, thread const float& _p2) +{ + return (_p2 - _p0) / (_p1 - _p0); +} + +static inline __attribute__((always_inline)) +float4 _f2(thread const float4& _p0) +{ + float4 _68 = _p0 * _p0; + float4 _72 = _68 * _68; + return (((_72 * _72) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f3(texture2d _p0, sampler _p0Smplr, texture2d _p1, sampler _p1Smplr, thread const float2& _p2, thread const float& _p3, thread const float2& _p4, constant float& u_regionIns, constant int& u_samples, constant float& u_angle0, constant float2& u_scale, constant int& u_pointCount, constant spvUnsafeArray& u_contours, constant float& u_lightIns) +{ + float _96 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _100 = float2(1.0) / _p4; + float2 _104 = _p2 * _p4; + float _110 = float(u_samples); + float _114 = _p3 / _110; + float4 _t12 = float4(0.0); + float4 _t13 = float4(0.0); + float4 _t14 = float4(0.0); + float param = u_angle0; + float2x2 _124 = _f0(param); + int _128 = -u_samples; + for (int _t16 = _128; _t16 <= u_samples; _t16++) + { + float _140 = float(_t16); + float _143 = -_110; + float param_1 = _143; + float param_2 = _110; + float param_3 = _140; + float _149 = _f1(param_1, param_2, param_3); + for (int _t19 = _128; _t19 <= u_samples; _t19++) + { + float _163 = float(_t19); + float param_4 = _143; + float param_5 = _110; + float param_6 = _163; + if (0.5 > _p1.sample(_p1Smplr, float2(_149, _f1(param_4, param_5, param_6))).x) + { + continue; + } + float4 _208 = _p0.sample(_p0Smplr, ((_104 + (_124 * ((float2(_140, _163) * u_scale) * _114))) * _100)); + float4 param_7 = _208; + float4 _214 = _f2(param_7) * u_regionIns; + _t12 = fast::max(_t12, _208 * _96); + _t13 += (_208 * _214); + _t14 += _214; + } + } + for (int _t26 = 0; _t26 < 500; _t26++) + { + if (_t26 >= u_pointCount) + { + break; + } + float4 _281 = _p0.sample(_p0Smplr, ((_104 + (_124 * ((((u_contours[_t26] * 2.0) - float2(1.0)) * u_scale) * _p3))) * _100)); + float4 param_8 = _281; + float4 _285 = _f2(param_8); + _t12 = fast::max(_t12, _281); + _t13 += (_281 * _285); + _t14 += _285; + } + float4 _305 = fast::clamp(_t13 / _t14, float4(0.0), float4(1.0)); + return float4(mix(_305, _t12, fast::clamp(_305 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], texture2d u_maskTex [[texture(1)]], sampler u_inputTexSmplr [[sampler(0)]], sampler u_maskTexSmplr [[sampler(1)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f3(u_inputTex, u_inputTexSmplr, u_maskTex, u_maskTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_samples, buffer.u_angle0, buffer.u_scale, buffer.u_pointCount, buffer.u_contours, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.frag new file mode 100644 index 0000000000000000000000000000000000000000..b0360d5d63c66e31836118d4e12d3d7f8246119c --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.frag @@ -0,0 +1,126 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_regionIns; + float u_angle0; + int u_samplesCore; + float2 u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return float2x2(float2(_36, -_33), float2(_33, _36)); +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float4& _p0) +{ + float4 _52 = _p0 * _p0; + float4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant float& u_angle0, constant int& u_samplesCore, constant float2& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _89 = float2(1.0) / _p3; + float2 _93 = _p1 * _p3; + float param = 0.00999999977648258209228515625; + float2 _t11 = _f0(param) * float2(1.0, 0.0); + float param_1 = 2.3999631404876708984375; + float2x2 _t12 = _f0(param_1); + float param_2 = u_angle0; + float2x2 _109 = _f0(param_2); + float4 _t14 = float4(0.0); + float4 _t15 = float4(0.0); + float4 _t16 = float4(0.0); + int _t17 = 0; + for (;;) + { + float _128 = float(u_samplesCore); + float _130 = _128 * 0.0500000007450580596923828125; + int _131 = int(_130); + int _132 = u_samplesCore - _131; + if (_t17 <= _132) + { + float _154 = abs(_t11.y * 8.659999847412109375); + float _159 = abs(_t11.x * 8.659999847412109375); + float _161 = 2.2999999523162841796875 * sqrt(_159); + float4 _219 = _p0.sample(_p0Smplr, ((_93 + (_109 * ((_t11 * (sqrt(float(_t17) / _128) * _p2)) * float2(u_scale.x, u_scale.y * (mix(((_154 - _161) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _159))) + 3.0, (_154 + _161) - 3.0, step(0.0, _t11.y)) / (_154 + 1.0000000133514319600180897396058e-10)))))) * _89)); + float4 param_3 = _219; + float4 _227 = _f1(param_3) * (u_regionIns * 2.0); + _t14 = fast::max(_t14, _219 * _80); + _t15 += (_219 * _227); + _t16 += _227; + _t11 = _t12 * _t11; + _t17++; + continue; + } + else + { + break; + } + } + float _252 = 6.283185482025146484375 / float(u_samplesEdge); + float param_4 = _252 * 0.5; + _t11 = _f0(param_4) * float2(1.0, 0.0); + float param_5 = _252; + _t12 = _f0(param_5); + for (int _t29 = 0; _t29 < u_samplesEdge; _t29++) + { + float _279 = abs(_t11.y * 8.659999847412109375); + float _283 = abs(_t11.x * 8.659999847412109375); + float _285 = 2.2999999523162841796875 * sqrt(_283); + float4 _336 = _p0.sample(_p0Smplr, ((_93 + (_109 * ((_t11 * _p2) * float2(u_scale.x, u_scale.y * (mix(((_279 - _285) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _283))) + 3.0, (_279 + _285) - 3.0, step(0.0, _t11.y)) / (_279 + 1.0000000133514319600180897396058e-10)))))) * _89)); + float4 param_6 = _336; + float4 _340 = _f1(param_6); + _t14 = fast::max(_t14, _336); + _t15 += (_336 * _340); + _t16 += _340; + _t11 = _t12 * _t11; + } + float4 _363 = fast::clamp(_t15 / _t16, float4(0.0), float4(1.0)); + return float4(mix(_363, _t14, fast::clamp(_363 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f2(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_angle0, buffer.u_samplesCore, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.frag new file mode 100644 index 0000000000000000000000000000000000000000..d8bdd8b92d28d76ff40fcf75e84f7c65ba6f4e43 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.frag @@ -0,0 +1,60 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_samples; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float2& _p2, constant int& u_samples) +{ + float param = 0.0; + float param_1 = 4.0; + float _48 = _f0(param, param_1); + float _t1 = _48; + float2 _t2 = float2(1.0) / _p2; + float4 _t3 = _p0.sample(_p0Smplr, _p1) * _48; + float _66 = float(u_samples); + for (int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _66) * 15.0; + float param_3 = 4.0; + float _91 = _f0(param_2, param_3); + float2 _100 = float2(0.0, _t2.y * float(_t5)); + _t3 = (_t3 + (_p0.sample(_p0Smplr, (_p1 + _100)) * _91)) + (_p0.sample(_p0Smplr, (_p1 - _100)) * _91); + _t1 += (_91 + _91); + } + return _t3 / float4(_t1); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float2 param = in.v_uv; + float2 param_1 = buffer.u_screenSize; + out.o_fragColor = _f1(u_inputTex, u_inputTexSmplr, param, param_1, buffer.u_samples); + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.frag new file mode 100644 index 0000000000000000000000000000000000000000..a83bc011d7993d7bd0504aac94fe389c7a1bc1b5 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.frag @@ -0,0 +1,118 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float u_regionIns; + float u_angle0; + int u_lineNum; + int u_samplesCore; + float u_shapeIns; + float u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f0(thread const float4& _p0) +{ + float4 _29 = _p0 * _p0; + float4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant float& u_angle0, constant int& u_lineNum, constant int& u_samplesCore, constant float& u_shapeIns, constant float& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _66 = float2(1.0) / _p3; + float2 _70 = _p1 * _p3; + float4 _t10 = float4(0.0); + float4 _t11 = float4(0.0); + float4 _t12 = float4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + float2 _t15 = float2(1.0, 0.0); + float2x2 _t16 = float2x2(float2(-0.737368881702423095703125, -0.675490319728851318359375), float2(0.675490319728851318359375, -0.737368881702423095703125)); + float _101 = 6.283185482025146484375 / float(u_lineNum); + float _105 = _101 * 0.5; + float _108 = sin(_105); + for (int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _129 = _t13; + float _135 = abs(mod(_129, _101) - _105); + float _149 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _135)) + sin(_135)); + float4 _171 = _p0.sample(_p0Smplr, ((_70 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _149))) * _66)); + float4 param = _171; + float4 _181 = _f0(param) * ((u_regionIns * _149) * _149); + _t10 = fast::max(_t10, _171 * _58); + _t11 += (_171 * _181); + _t13 += _t14; + _t12 += _181; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + float _208 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _208; + float _210 = cos(_208); + float _212 = sin(_208); + _t15 = float2(_p2, 0.0); + _t16 = float2x2(float2(_210, -_212), float2(_212, _210)); + for (int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + float _239 = _t13; + float _245 = abs(mod(_239, _101) - _105); + float _258 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _245)) + sin(_245)); + float4 _272 = _p0.sample(_p0Smplr, ((_70 + ((_t15 * u_scale) * _258)) * _66)); + float4 param_1 = _272; + float4 _280 = _f0(param_1) * (_258 * _258); + _t10 = fast::max(_t10, _272); + _t11 += (_272 * _280); + _t13 += _t14; + _t12 += _280; + _t15 = _t16 * _t15; + } + float4 _306 = fast::clamp(_t11 / _t12, float4(0.0), float4(1.0)); + return float4(mix(_306, _t10, fast::clamp(_306 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f1(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_angle0, buffer.u_lineNum, buffer.u_samplesCore, buffer.u_shapeIns, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/lua/ScriptCompSaturation.lua b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/lua/ScriptCompSaturation.lua new file mode 100644 index 0000000000000000000000000000000000000000..91e8e7bb5e79c5290fef82fd11480ef7e44b0b22 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/lua/ScriptCompSaturation.lua @@ -0,0 +1,71 @@ +---@class ScriptCompSaturation: ScriptComponent +---@field saturationIntensity number [UI(Range={-1., 1.}, Drag)] +---@field InputTex Texture +---@field OutputTex Texture + +local exports = exports or {} +local ScriptCompSaturation = ScriptCompSaturation or {} +ScriptCompSaturation.__index = ScriptCompSaturation + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompSaturation.new(construct, ...) + local self = setmetatable({}, ScriptCompSaturation) + + if construct and ScriptCompSaturation.constructor then ScriptCompSaturation.constructor(self, ...) end + -- user parameters + self.saturationIntensity = 0. + + -- other parameters + self.MinIntensity = -1. + self.MaxIntensity = 1. + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompSaturation:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "saturationIntensity" then + _setEffectAttr(key, value, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompSaturation:onStart(comp) + self.matSaturation = comp.entity:searchEntity("EntitySaturation"):getComponent("MeshRenderer").material + self.camSaturation = comp.entity:searchEntity("CameraSaturation"):getComponent("Camera") +end + +function ScriptCompSaturation:onUpdate(comp, deltaTime) + -- prepare parameters + self.saturationIntensity = clamp(self.saturationIntensity, self.MinIntensity, self.MaxIntensity) + local intensity = self.saturationIntensity + 1.0 + + -- set InputTex and OutputTex + self.matSaturation:setTex("u_inputTexture", self.InputTex) + self.camSaturation.renderTexture = self.OutputTex + + -- set material parameters + self.matSaturation:setFloat("u_intensity", intensity) +end + +exports.ScriptCompSaturation = ScriptCompSaturation +return exports diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderGLES/e2647663d9a4d2e4272be5df1b56c8c3.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderGLES/e2647663d9a4d2e4272be5df1b56c8c3.frag new file mode 100644 index 0000000000000000000000000000000000000000..6d9c578d0ebf1db99434593e6e5a7a8beb2eb354 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderGLES/e2647663d9a4d2e4272be5df1b56c8c3.frag @@ -0,0 +1,20 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_inputTexture; +uniform float u_intensity; + +varying vec2 v_uv; + +void main() +{ + mediump vec4 _19 = texture2D(u_inputTexture, v_uv); + vec4 _t1 = _19; + vec3 _34 = vec3(0.2085399925708770751953125, 0.702085971832275390625, 0.089373998343944549560546875) * (1.0 - u_intensity); + vec3 _42 = _19.xyz; + _t1.x = dot(_42, _34 + vec3(u_intensity, 0.0, 0.0)); + _t1.y = dot(_42, _34 + vec3(0.0, u_intensity, 0.0)); + _t1.z = dot(_42, _34 + vec3(0.0, 0.0, u_intensity)); + gl_FragData[0] = clamp(_t1, vec4(0.0), vec4(1.0)); +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderGLES/e2647663d9a4d2e4272be5df1b56c8c3.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderGLES/e2647663d9a4d2e4272be5df1b56c8c3.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderGLES/e2647663d9a4d2e4272be5df1b56c8c3.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderMetal/e2647663d9a4d2e4272be5df1b56c8c3.frag b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderMetal/e2647663d9a4d2e4272be5df1b56c8c3.frag new file mode 100644 index 0000000000000000000000000000000000000000..5e58d2ba763dd52dd4c1b8b722ed6742dceed0ef --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderMetal/e2647663d9a4d2e4272be5df1b56c8c3.frag @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_intensity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _19 = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + float4 _t1 = _19; + float3 _34 = float3(0.2085399925708770751953125, 0.702085971832275390625, 0.089373998343944549560546875) * (1.0 - buffer.u_intensity); + float3 _42 = _19.xyz; + _t1.x = dot(_42, _34 + float3(buffer.u_intensity, 0.0, 0.0)); + _t1.y = dot(_42, _34 + float3(0.0, buffer.u_intensity, 0.0)); + _t1.z = dot(_42, _34 + float3(0.0, 0.0, buffer.u_intensity)); + out.o_fragColor = fast::clamp(_t1, float4(0.0), float4(1.0)); + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderMetal/e2647663d9a4d2e4272be5df1b56c8c3.vert b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderMetal/e2647663d9a4d2e4272be5df1b56c8c3.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/effects/LumiSaturation/xshader/shaderLib/shaderMetal/e2647663d9a4d2e4272be5df1b56c8c3.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..e419ea761111d5a6d768c09e08ddd33620c0984d --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,659 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiAnimSeqLoadAndCrop_533-effect0', 'seqTex_1_1', 1}, + {'LumiAnimSeqLoadAndCrop_531-effect0', 'seqTex_1_1', 0}, + {'LumiLayer_49-blend', 'InputTex', 1}, + {'LumiLayer_49-blend', 'baseTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiAnimSeqLoadAndCrop_533-effect0'] = { + ['nodeDuration'] = {{0.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.66666666666667, 2}, }, + ['seqTex_1_1'] = {{1.03333333333333, 5}, }, + }, + }, + ['LumiBokehBlur_533-effect1'] = { + ['nodeDuration'] = {{0.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.66666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_531-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 5}, }, + }, + }, + ['LumiBokehBlur_531-effect1'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_49-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{1.03333333333333, 5}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, + ['LumiLayer_531-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, + ['LumiLayer_533-trs-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{0.66666666666667, 2}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_535-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiBCCGlowOBS_535-effect1'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiSaturation_535-effect2'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_535-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiAnimSeqLoadAndCrop_533-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 2, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = false, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiBokehBlur_533-effect1'] = { + ['bokehMode'] = 0, + ['scale'] = 0, + ['scaleX'] = 1, + ['scaleY'] = 1, + ['regionIns'] = 0.5, + ['lightIns'] = 4, + ['darkIns'] = 2, + ['quality'] = 0.69999998807907, + ['angle'] = 0, + ['lineNum'] = 5, + ['shapeIns'] = 0.6, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiAnimSeqLoadAndCrop_531-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 2, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = false, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiBokehBlur_531-effect1'] = { + ['bokehMode'] = 0, + ['scale'] = 30, + ['scaleX'] = 1, + ['scaleY'] = 1, + ['regionIns'] = 0.5, + ['lightIns'] = 4, + ['darkIns'] = 2, + ['quality'] = 0.69999998807907, + ['angle'] = 0, + ['lineNum'] = 5, + ['shapeIns'] = 0.6, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_49-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiLayer_531-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Solid', + ['blendMode'] = 0, + }, + ['LumiLayer_533-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_535-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiBCCGlowOBS_535-effect1'] = { + ['show'] = 2, + ['glowChannels'] = 0, + ['glowThreshold'] = 0.55, + ['glowRadius'] = 50, + ['glowAspectRatio'] = 0, + ['glowIntensity'] = 1, + ['combine'] = 1, + ['colorA'] = Amaz.Color(0, 0, 0, 1), + ['colorB'] = Amaz.Color(1, 1, 1, 1), + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiSaturation_535-effect2'] = { + ['saturationIntensity'] = 1, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_535-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Solid', + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiBokehBlur_533-effect1#scale#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.1, 1.666667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiBokehBlur_531-effect1#scale#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.333333, 0.833333, }, + {{0, }, {30, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiLayer_533-trs-blend#opacity#number'] = +{ + { + {0.899416631, 0, 0.66666667, 1, }, + {0.666667, 1.033333, }, + {{0, }, {100, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_535-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681186508522523912/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681186508522523912/config.json b/scripts/7681186508522523912/config.json new file mode 100644 index 0000000000000000000000000000000000000000..6cfdba3471113cd3425236fa5399a84e18415f5a --- /dev/null +++ b/scripts/7681186508522523912/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.5", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903121549466", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681186508522523912/extra.json b/scripts/7681186508522523912/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681186508522523912/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681200609197821202/AmazingFeature/content.json b/scripts/7681200609197821202/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..a498e06b924f116108617c6860cb4ca1fd5e9b15 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,327 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setTex("u_seqTexture", self.InputTex) + local inputWidth = Amaz.BuiltinObject.getInputTextureWidth() + local inputHeight = Amaz.BuiltinObject.getInputTextureHeight() + local videoSize = Amaz.Vector2f(inputWidth, inputHeight) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/lua/BCCGlow.lua b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/lua/BCCGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6c712a949a345735f56f8a0f0f159b5bfc6a2d19 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/lua/BCCGlow.lua @@ -0,0 +1,170 @@ +local exports = exports or {} +local BCCGlow = BCCGlow or {} +BCCGlow.__index = BCCGlow +---@class BCCGlow: ScriptComponent +---@field show int [UI(Range={0, 2}, Slider)] +---@field glowChannels int [UI(Range={0, 6}, Slider)] +---@field glowThreshold double [UI(Range={0, 1}, Drag)] +---@field glowRadius double [UI(Range={0, 50}, Drag)] +---@field glowAspectRatio double [UI(Range={-1, 1}, Drag)] +---@field glowIntensity double [UI(Range={0, 3}, Drag)] +---@field delta double [UI(Range={0, 0.1}, Drag)] +--- @field step int [UI(Range={0, 10}, Slider)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay", "Darken", "Lighten", "SoftLight", "HardLight", "Over", "Hue", "Saturation", "Color"})] +---@field colorA Color [UI(NoAlpha)] +---@field colorB Color [UI(NoAlpha)] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field quality double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay", "Darken", "Lighten", "SoftLight", "HardLight", "Over", "Hue", "Saturation", "Color" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do CombineModeIndex[value] = index - 1 end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeMode = { + Transparent = 0, Reflect = 1 +} + +function BCCGlow.new(construct, ...) + local self = setmetatable({}, BCCGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.show = 2 + self.glowChannels = 0 -- 0: rgb, 1: red, 2: green, 3: blue, 4: alpha, 5: luminance, 6: brightness + self.glowThreshold = 0.5 + self.delta = 0.075 + self.step = 0; + self.glowRadius = 0 + self.glowAspectRatio = 0 + self.glowIntensity = 1 + self.colorA = Amaz.Color(0., 0., 0.) + self.colorB = Amaz.Color(1., 1., 1.) + self.combine = 'Add' + self.edgeMode = 'Reflect' + self.quality = 0.2 + + return self +end + +function BCCGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.maskCamera = self.entity:searchEntity('MaskCamera'):getComponent('Camera') + self.horzBlurCameraEntity = self.entity:searchEntity('HorzBlurCamera') + self.vertBlurCameraEntity = self.entity:searchEntity('VertBlurCamera') + self.blendCameraEntity = self.entity:searchEntity('BlendCamera') + self.blendCamera = self.blendCameraEntity:getComponent('Camera') + self.maskMat = self.entity:searchEntity('MaskPass'):getComponent('MeshRenderer').material + self.horzBlurMat = self.entity:searchEntity('HorzBlurPass'):getComponent('MeshRenderer').material + self.vertBlurMat = self.entity:searchEntity('VertBlurPass'):getComponent('MeshRenderer').material + self.blendMat = self.entity:searchEntity('BlendPass'):getComponent('MeshRenderer').material + self.horzBlurCamera = self.horzBlurCameraEntity:getComponent('Camera') + self.vertBlurCamera = self.vertBlurCameraEntity:getComponent('Camera') +end + +function BCCGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if 'combine' == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine, comp) + else + _setEffectAttr(key, value, comp) + end + +end + +function BCCGlow:onUpdate(comp, deltaTime) + self.maskMat:setTex('u_InputTexture', self.InputTex) + self.blendMat:setTex('u_InputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show ~= 0 + self.horzBlurCameraEntity.visible = isShowResult + self.vertBlurCameraEntity.visible = isShowResult + self.blendCameraEntity.visible = isShowResult + if isShowResult then + self.maskCamera.renderTexture = self.blurTex + else + self.maskCamera.renderTexture = self.OutputTex + end + + if self.glowRadius == 0 then + self.horzBlurCameraEntity.visible = false + self.vertBlurCameraEntity.visible = false + end + + -- Amaz.LOGS('tqh-log', self.maskMat:getTex('inputTexture').width .. 'x' .. self.maskMat:getTex('inputTexture').height) + + self.maskMat:setInt('u_GlowChannels', self.glowChannels) + self.maskMat:setFloat('u_Threshold', self.glowThreshold) + self.maskMat:setFloat('u_Delta', self.delta) + self.maskMat:setInt('u_Step', self.step) + + local blurWidth = self.OutputTex.width + local blurHeight = self.OutputTex.height + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowRadius * (blurSize / 360) + local radiusX = radius + local radiusY = radius + if self.glowAspectRatio > 0 then + radiusY = radius * (1.0 - self.glowAspectRatio) + elseif self.glowAspectRatio < 0 then + radiusX = radius * (1.0 - math.abs(self.glowAspectRatio)) + end + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + self.horzBlurCamera.renderTexture.width = math.floor(blurWidth) + self.horzBlurCamera.renderTexture.height = math.floor(blurHeight) + self.vertBlurCamera.renderTexture.width = math.floor(blurWidth) + self.vertBlurCamera.renderTexture.height = math.floor(blurHeight) + self.horzBlurMat:setFloat('u_Radius', radiusX) + self.vertBlurMat:setFloat('u_Radius', radiusY) + self.horzBlurMat:setFloat("u_MaxRadius", 5 + math.floor(50 * self.quality)) + self.vertBlurMat:setFloat("u_MaxRadius", 5 + math.floor(50 * self.quality)) + local sigma = radius / 2.4 + sigma = math.pow(sigma, 2) * 2.0 + self.horzBlurMat:setFloat('u_Sigma', sigma) + self.vertBlurMat:setFloat('u_Sigma', sigma) + self.horzBlurMat:setInt('u_edgeMode', EdgeMode[self.edgeMode]) + self.vertBlurMat:setInt('u_edgeMode', EdgeMode[self.edgeMode]) + + self.blendMat:setFloat('u_Intensity', self.glowIntensity) + self.blendMat:setFloat('u_Threshold', self.glowThreshold) + self.blendMat:setInt('u_GlowChannels', self.glowChannels) + self.blendMat:setVec3('u_ColorA', Amaz.Vector3f(self.colorA.r, self.colorA.g, self.colorA.b)) + self.blendMat:setVec3('u_ColorB', Amaz.Vector3f(self.colorB.r, self.colorB.g, self.colorB.b)) + self.blendMat:setInt('u_Combine', CombineModeIndex[self.combine]) + self.blendMat:setInt('u_ShowMode', self.show) + -- Amaz.LOGS('tqh-log combine: ', self.combine) +end + +exports.BCCGlow = BCCGlow +return exports diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.frag new file mode 100644 index 0000000000000000000000000000000000000000..e83bdaa6300cf8e82bca52c6ef3e3f4957d459f4 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.frag @@ -0,0 +1,111 @@ +precision highp float; +precision highp int; + +uniform float u_Delta; +uniform mediump sampler2D u_InputTexture; +uniform mediump int u_GlowChannels; +uniform float u_Threshold; + +varying vec2 uv0; + +float _f2(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +float _f1(vec3 _p0) +{ + float _99 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_99, _p0.x, step(_99, _p0.x)); +} + +float _f3(vec2 _p0) +{ + mediump vec4 _125 = texture2D(u_InputTexture, _p0); + vec4 _t4 = _125; + if (u_GlowChannels == 5) + { + vec3 param = _125.xyz; + return _f2(param); + } + else + { + if (u_GlowChannels == 6) + { + vec3 param_1 = _125.xyz; + return _f1(param_1); + } + else + { + if (u_GlowChannels == 1) + { + return _t4.x; + } + else + { + if (u_GlowChannels == 2) + { + return _t4.y; + } + else + { + if (u_GlowChannels == 3) + { + return _t4.z; + } + else + { + if (u_GlowChannels == 4) + { + return _t4.w; + } + } + } + } + } + } + return _t4.w; +} + +vec4 _f0(float _p0, float _p1) +{ + vec4 _t0 = vec4(0.0); + float _41 = clamp(_p1, u_Delta, 1.0 - u_Delta); + float _55 = smoothstep(_41 - u_Delta, _41, _p0) - smoothstep(_41, _41 + u_Delta, _p0); + _t0.x = _55; + float _64 = u_Delta / 2.0; + if (_p0 < (_41 - _64)) + { + _t0.x = 1.0; + } + _t0.y = _55 * 0.5; + if (_p0 > (_41 + _64)) + { + _t0.y = 1.0; + } + return _t0; +} + +void main() +{ + vec4 _t5 = vec4(0.0); + if (u_GlowChannels == 0) + { + vec4 _t6 = texture2D(u_InputTexture, uv0); + float _207 = u_Threshold - u_Delta; + float _210 = u_Threshold + u_Delta; + vec3 _237 = vec3(smoothstep(_207, _210, _t6.x), smoothstep(_207, _210, _t6.y), smoothstep(_207, _210, _t6.z)); + _t5.x = _237.x; + _t5.y = _237.y; + _t5.z = _237.z; + } + else + { + vec2 param = uv0; + float param_1 = _f3(param); + float param_2 = u_Threshold; + _t5 = _f0(param_1, param_2); + } + gl_FragData[0] = _t5; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/293d6f5a9a94d4e5892d2f8968a99f0b.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.frag new file mode 100644 index 0000000000000000000000000000000000000000..665b297eaf61e20a101546248650f71e96c09349 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.frag @@ -0,0 +1,85 @@ +precision highp float; +precision highp int; + +uniform mediump int u_edgeMode; +uniform vec4 u_ScreenParams; +uniform mediump sampler2D u_InputTexture; +uniform float u_Radius; +uniform float u_MaxRadius; +uniform float u_Sigma; + +varying vec2 uv0; + +float _f2(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +vec2 _f0(float _p0, float _p1) +{ + vec2 _t0 = vec2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +vec4 _f1(float _p0) +{ + vec2 _67 = vec2(1.0) / u_ScreenParams.xy; + vec2 _76 = uv0 + (_67 * vec2(0.0, _p0)); + vec2 _t2 = _76; + vec2 _83 = uv0 - (_67 * vec2(0.0, _p0)); + vec2 _t3 = _83; + float param = _t2.y; + float param_1 = _t3.y; + vec2 _t4 = _f0(param, param_1); + return (texture2D(u_InputTexture, _76) * _t4.x) + (texture2D(u_InputTexture, _83) * _t4.y); +} + +vec4 _f3(inout vec4 _p0) +{ + vec4 _t5 = vec4(1.0); + vec4 _t6 = vec4(0.0); + float _134 = max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +void main() +{ + vec4 param = texture2D(u_InputTexture, uv0); + vec4 _238 = _f3(param); + gl_FragData[0] = _238; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/4854f390a866b96321acae596f212a75.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.frag new file mode 100644 index 0000000000000000000000000000000000000000..c409c9309bcb40e9f27e2978ce119175fa009ade --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.frag @@ -0,0 +1,627 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_InputTexture; +uniform mediump sampler2D u_BlurTexture; +uniform mediump int u_ShowMode; +uniform float u_Intensity; +uniform mediump int u_Combine; +uniform mediump int u_GlowChannels; +uniform vec3 u_ColorB; +uniform float u_Threshold; +uniform vec3 u_ColorA; + +varying vec2 v_uv; + +vec3 _1240; + +float _f5(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +float _f4(vec3 _p0) +{ + float _203 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_203, _p0.x, step(_203, _p0.x)); +} + +float _f0(float _p0, float _p1) +{ + float _67; + if (_p0 < 0.5) + { + _67 = _p1 - (((1.0 - (2.0 * _p0)) * _p1) * (1.0 - _p1)); + } + else + { + float _86; + if (_p1 < 0.25) + { + _86 = _p1 + ((((2.0 * _p0) - 1.0) * _p1) * ((((16.0 * _p1) - 12.0) * _p1) + 3.0)); + } + else + { + _86 = _p1 + (((2.0 * _p0) - 1.0) * (sqrt(_p1) - _p1)); + } + _67 = _86; + } + return _67; +} + +vec3 _f1(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f0(param, param_1), _f0(param_2, param_3), _f0(param_4, param_5)); +} + +float _f2(float _p0, float _p1) +{ + float _151; + if (_p0 < 0.5) + { + _151 = (2.0 * _p0) * _p1; + } + else + { + _151 = 1.0 - ((2.0 * (1.0 - _p0)) * (1.0 - _p1)); + } + return _151; +} + +vec3 _f3(vec3 _p0, vec3 _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return vec3(_f2(param, param_1), _f2(param_2, param_3), _f2(param_4, param_5)); +} + +float _f8(vec3 _p0) +{ + return max(_p0.x, max(_p0.y, _p0.z)) - min(_p0.x, min(_p0.y, _p0.z)); +} + +vec3 _f7(inout vec3 _p0, float _p1) +{ + if (_p0.z > _p0.x) + { + _p0.y = ((_p0.y - _p0.x) * _p1) / (_p0.z - _p0.x); + _p0.z = _p1; + } + else + { + _p0.y = 0.0; + _p0.z = 0.0; + } + _p0.x = 0.0; + return _p0; +} + +vec3 _f9(inout vec3 _p0, float _p1) +{ + bool _343 = _p0.x <= _p0.y; + bool _351; + if (_343) + { + _351 = _p0.x <= _p0.z; + } + else + { + _351 = _343; + } + if (_351) + { + if (_p0.y <= _p0.z) + { + vec3 param = _p0; + float param_1 = _p1; + vec3 _365 = _f7(param, param_1); + _p0 = _365; + } + else + { + vec3 param_2 = _p0.xzy; + float param_3 = _p1; + vec3 _372 = _f7(param_2, param_3); + _p0 = vec3(_372.x, _372.z, _372.y); + } + } + else + { + bool _380 = _p0.y <= _p0.x; + bool _388; + if (_380) + { + _388 = _p0.y <= _p0.z; + } + else + { + _388 = _380; + } + if (_388) + { + if (_p0.x <= _p0.z) + { + vec3 param_4 = _p0.yxz; + float param_5 = _p1; + vec3 _403 = _f7(param_4, param_5); + _p0 = vec3(_403.y, _403.x, _403.z); + } + else + { + vec3 param_6 = _p0.yzx; + float param_7 = _p1; + vec3 _412 = _f7(param_6, param_7); + _p0 = vec3(_412.z, _412.x, _412.y); + } + } + else + { + if (_p0.x <= _p0.y) + { + vec3 param_8 = _p0.zxy; + float param_9 = _p1; + vec3 _428 = _f7(param_8, param_9); + _p0 = vec3(_428.y, _428.z, _428.x); + } + else + { + vec3 param_10 = _p0.zyx; + float param_11 = _p1; + vec3 _437 = _f7(param_10, param_11); + _p0 = vec3(_437.z, _437.y, _437.x); + } + } + } + return _p0; +} + +vec3 _f6(inout vec3 _p0, inout float _p1) +{ + vec3 param = _p0; + _p0 += vec3(_p1 - _f5(param)); + vec3 param_1 = _p0; + _p1 = _f5(param_1); + float _243 = min(_p0.x, min(_p0.y, _p0.z)); + float _246 = _p0.x; + float _248 = _p0.y; + float _250 = _p0.z; + float _252 = max(_246, max(_248, _250)); + if (_243 < 0.0) + { + _p0 = mix(vec3(_p1, _p1, _p1), _p0, vec3(_p1 / (_p1 - _243))); + } + if (_252 > 1.0) + { + _p0 = mix(vec3(_p1, _p1, _p1), _p0, vec3((1.0 - _p1) / (_252 - _p1))); + } + return _p0; +} + +vec3 _f10(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + float param_2 = _f8(param); + vec3 _449 = _f9(param_1, param_2); + vec3 param_3 = _p1; + vec3 param_4 = _449; + float param_5 = _f5(param_3); + vec3 _455 = _f6(param_4, param_5); + return _455; +} + +vec3 _f11(vec3 _p0, vec3 _p1) +{ + vec3 param = _p0; + vec3 param_1 = _p1; + float param_2 = _f8(param); + vec3 _464 = _f9(param_1, param_2); + vec3 param_3 = _p1; + vec3 param_4 = _464; + float param_5 = _f5(param_3); + vec3 _470 = _f6(param_4, param_5); + return _470; +} + +vec3 _f12(vec3 _p0, vec3 _p1) +{ + vec3 param = _p1; + vec3 param_1 = _p0; + float param_2 = _f5(param); + vec3 _479 = _f6(param_1, param_2); + return _479; +} + +void main() +{ + mediump vec4 _494 = texture2D(u_InputTexture, v_uv); + vec4 _t4 = _494; + mediump vec4 _499 = texture2D(u_BlurTexture, v_uv); + vec4 _t5 = _499; + float _504 = (_t5.y * 2.0) - 1.0; + float _511 = (1.0 - abs(_504)) * _t5.y; + float _517 = step(_504, 0.0) * (0.5 - _511); + if (u_ShowMode == 1) + { + gl_FragData[0] = _499 * u_Intensity; + if (u_Combine == 2) + { + gl_FragData[0] = _499.xxxx * u_Intensity; + } + else + { + if (u_GlowChannels != 0) + { + gl_FragData[0] = vec4(vec3(_511) * u_Intensity, 1.0); + } + } + return; + } + vec4 _t9 = _499; + bool _562 = u_GlowChannels != 0; + if (_562) + { + if (u_Combine == 2) + { + _t9 = _499.xxxx; + } + else + { + _t9 = vec4(_511); + } + vec4 _577 = _t9; + vec3 _579 = _577.xyz * u_ColorB; + _t9.x = _579.x; + _t9.y = _579.y; + _t9.z = _579.z; + } + vec4 _587 = _t9; + vec3 _589 = _587.xyz * u_Intensity; + _t9.x = _589.x; + _t9.y = _589.y; + _t9.z = _589.z; + vec4 _596 = _t9; + vec3 _600 = clamp(_596.xyz, vec3(0.0), vec3(1.0)); + _t9.x = _600.x; + _t9.y = _600.y; + _t9.z = _600.z; + float _t10 = 0.0; + if (u_GlowChannels == 1) + { + _t10 = _t4.x; + } + else + { + if (u_GlowChannels == 2) + { + _t10 = _t4.y; + } + else + { + if (u_GlowChannels == 3) + { + _t10 = _t4.z; + } + else + { + if (u_GlowChannels == 4) + { + _t10 = _t4.w; + } + else + { + if (u_GlowChannels == 5) + { + vec3 param = _494.xyz; + _t10 = _f5(param); + } + else + { + if (u_GlowChannels == 6) + { + vec3 param_1 = _494.xyz; + _t10 = _f4(param_1); + } + } + } + } + } + } + vec4 _t11 = _494; + if (u_Combine == 1) + { + vec3 _668 = _t9.xyz + _494.xyz; + _t11.x = _668.x; + _t11.y = _668.y; + _t11.z = _668.z; + } + else + { + if (u_Combine == 2) + { + vec3 _684 = _t9.xyz * _494.xyz; + _t11.x = _684.x; + _t11.y = _684.y; + _t11.z = _684.z; + } + else + { + if (u_Combine == 3) + { + vec3 _701 = abs(_t9.xyz - _494.xyz); + _t11.x = _701.x; + _t11.y = _701.y; + _t11.z = _701.z; + } + else + { + if (u_Combine == 4) + { + if (_562) + { + vec4 _718 = _t9; + vec3 _721 = _718.xyz + vec3(_517); + _t9.x = _721.x; + _t9.y = _721.y; + _t9.z = _721.z; + } + float _731; + if (_t4.x < 0.5) + { + _731 = (2.0 * _t4.x) * _t9.x; + } + else + { + _731 = 1.0 - ((2.0 * (1.0 - _t4.x)) * (1.0 - _t9.x)); + } + float _754; + if (_t4.y < 0.5) + { + _754 = (2.0 * _t4.y) * _t9.y; + } + else + { + _754 = 1.0 - ((2.0 * (1.0 - _t4.y)) * (1.0 - _t9.y)); + } + float _777; + if (_t4.z < 0.5) + { + _777 = (2.0 * _t4.z) * _t9.z; + } + else + { + _777 = 1.0 - ((2.0 * (1.0 - _t4.z)) * (1.0 - _t9.z)); + } + vec3 _797 = vec3(_731, _754, _777); + _t11.x = _797.x; + _t11.y = _797.y; + _t11.z = _797.z; + } + else + { + if (u_Combine == 5) + { + if (_562) + { + vec4 _814 = _t9; + vec3 _817 = _814.xyz + vec3(_517); + _t9.x = _817.x; + _t9.y = _817.y; + _t9.z = _817.z; + } + vec4 _824 = _t9; + vec3 _826 = _824.xyz * 2.0; + _t9.x = _826.x; + _t9.y = _826.y; + _t9.z = _826.z; + vec3 _837 = min(_t9.xyz, _494.xyz); + _t11.x = _837.x; + _t11.y = _837.y; + _t11.z = _837.z; + } + else + { + if (u_Combine == 6) + { + vec3 _853 = max(_t9.xyz, _494.xyz); + _t11.x = _853.x; + _t11.y = _853.y; + _t11.z = _853.z; + } + else + { + if (u_Combine == 7) + { + if (_562) + { + vec4 _871 = _t9; + vec3 _874 = _871.xyz + vec3(_517); + _t9.x = _874.x; + _t9.y = _874.y; + _t9.z = _874.z; + } + vec3 param_2 = _t9.xyz; + vec3 param_3 = _494.xyz; + vec3 _887 = _f1(param_2, param_3); + _t11.x = _887.x; + _t11.y = _887.y; + _t11.z = _887.z; + } + else + { + if (u_Combine == 8) + { + if (_562) + { + vec4 _905 = _t9; + vec3 _908 = _905.xyz + vec3(_517); + _t9.x = _908.x; + _t9.y = _908.y; + _t9.z = _908.z; + } + vec3 param_4 = _t9.xyz; + vec3 param_5 = _494.xyz; + vec3 _921 = _f3(param_4, param_5); + _t11.x = _921.x; + _t11.y = _921.y; + _t11.z = _921.z; + } + else + { + if (u_Combine == 9) + { + if (u_GlowChannels == 0) + { + _t11.x = _t9.xyz.x; + _t11.y = _t9.xyz.y; + _t11.z = _t9.xyz.z; + } + else + { + vec3 _951 = _494.xyz; + vec3 _974 = mix(mix(_t9.xyz, (_t9.xyz + _951) - (_t9.xyz * _951), vec3(clamp(_t9.x, 0.0, 1.0))), _951, vec3(clamp(_517 * 2.0, 0.0, 1.0))); + _t11.x = _974.x; + _t11.y = _974.y; + _t11.z = _974.z; + } + } + else + { + if (u_Combine == 10) + { + if (u_GlowChannels == 0) + { + vec3 param_6 = _t9.xyz; + vec3 param_7 = _494.xyz; + vec3 _997 = _f10(param_6, param_7); + _t11.x = _997.x; + _t11.y = _997.y; + _t11.z = _997.z; + } + else + { + vec4 _1006 = _t9; + vec3 _1009 = _1006.xyz + vec3(_517); + _t9.x = _1009.x; + _t9.y = _1009.y; + _t9.z = _1009.z; + vec3 param_8 = _t9.xyz; + vec3 _1021 = _494.xyz; + vec3 param_9 = _1021; + vec3 _1030 = mix(_f10(param_8, param_9), _1021, vec3(clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1030.x; + _t11.y = _1030.y; + _t11.z = _1030.z; + } + } + else + { + if (u_Combine == 11) + { + if (u_GlowChannels == 0) + { + vec3 param_10 = _t9.xyz; + vec3 param_11 = _494.xyz; + vec3 _1053 = _f11(param_10, param_11); + _t11.x = _1053.x; + _t11.y = _1053.y; + _t11.z = _1053.z; + } + else + { + vec4 _1062 = _t9; + vec3 _1065 = _1062.xyz + vec3(_517); + _t9.x = _1065.x; + _t9.y = _1065.y; + _t9.z = _1065.z; + vec3 param_12 = _t9.xyz; + vec3 _1077 = _494.xyz; + vec3 param_13 = _1077; + vec3 _1086 = mix(_f11(param_12, param_13), _1077, vec3(clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1086.x; + _t11.y = _1086.y; + _t11.z = _1086.z; + } + } + else + { + if (u_Combine == 12) + { + if (u_GlowChannels == 0) + { + vec3 param_14 = _t9.xyz; + vec3 param_15 = _494.xyz; + vec3 _1109 = _f12(param_14, param_15); + _t11.x = _1109.x; + _t11.y = _1109.y; + _t11.z = _1109.z; + } + else + { + vec4 _1118 = _t9; + vec3 _1121 = _1118.xyz + vec3(_517); + _t9.x = _1121.x; + _t9.y = _1121.y; + _t9.z = _1121.z; + vec3 param_16 = _t9.xyz; + vec3 _1133 = _494.xyz; + vec3 param_17 = _1133; + vec3 _1142 = mix(_f12(param_16, param_17), _1133, vec3(clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1142.x; + _t11.y = _1142.y; + _t11.z = _1142.z; + } + } + else + { + vec3 _1153 = _494.xyz; + vec3 _1160 = (_t9.xyz + _1153) - (_t9.xyz * _1153); + _t11.x = _1160.x; + _t11.y = _1160.y; + _t11.z = _1160.z; + } + } + } + } + } + } + } + } + } + } + } + } + if (_562) + { + if (_t10 > u_Threshold) + { + vec4 _1181 = _t11; + vec3 _1183 = _1181.xyz + (u_ColorA * _t10); + _t11.x = _1183.x; + _t11.y = _1183.y; + _t11.z = _1183.z; + } + if (((((((((u_Combine == 2) || (u_Combine == 4)) || (u_Combine == 5)) || (u_Combine == 7)) || (u_Combine == 8)) || (u_Combine == 9)) || (u_Combine == 10)) || (u_Combine == 11)) || (u_Combine == 12)) + { + _t11 = mix(_494, _t11, vec4(clamp(u_Intensity, 0.0, 1.0))); + } + } + vec4 _1224 = _t11; + float _1227 = _t11.w; + vec3 _1230 = clamp(_1224.xyz, vec3(0.0), vec3(_1227)); + _t11.x = _1230.x; + _t11.y = _1230.y; + _t11.z = _1230.z; + gl_FragData[0] = _t11; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/a068bda12b29d552633e491beca8b097.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.frag new file mode 100644 index 0000000000000000000000000000000000000000..d84dbf4124497cbf994ccb4da800ee6adc0b6f20 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.frag @@ -0,0 +1,85 @@ +precision highp float; +precision highp int; + +uniform mediump int u_edgeMode; +uniform vec4 u_ScreenParams; +uniform mediump sampler2D u_InputTexture; +uniform float u_Radius; +uniform float u_MaxRadius; +uniform float u_Sigma; + +varying vec2 uv0; + +float _f2(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +vec2 _f0(float _p0, float _p1) +{ + vec2 _t0 = vec2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +vec4 _f1(float _p0) +{ + vec2 _67 = vec2(1.0) / u_ScreenParams.xy; + vec2 _76 = uv0 + (_67 * vec2(_p0, 0.0)); + vec2 _t2 = _76; + vec2 _83 = uv0 - (_67 * vec2(_p0, 0.0)); + vec2 _t3 = _83; + float param = _t2.x; + float param_1 = _t3.x; + vec2 _t4 = _f0(param, param_1); + return (texture2D(u_InputTexture, _76) * _t4.x) + (texture2D(u_InputTexture, _83) * _t4.y); +} + +vec4 _f3(inout vec4 _p0) +{ + vec4 _t5 = vec4(1.0); + vec4 _t6 = vec4(0.0); + float _134 = max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +void main() +{ + vec4 param = texture2D(u_InputTexture, uv0); + vec4 _238 = _f3(param); + gl_FragData[0] = _238; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderGLES/c94c7a07a0da4a8023816dd0078a1657.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ab53c87492678668d7660caef88cf4ef43d4424 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.frag @@ -0,0 +1,131 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_Delta; + int u_GlowChannels; + float u_Threshold; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f2(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float _f1(thread const float3& _p0) +{ + float _99 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_99, _p0.x, step(_99, _p0.x)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0, texture2d u_InputTexture, sampler u_InputTextureSmplr, constant int& u_GlowChannels) +{ + float4 _125 = u_InputTexture.sample(u_InputTextureSmplr, _p0); + float4 _t4 = _125; + if (u_GlowChannels == 5) + { + float3 param = _125.xyz; + return _f2(param); + } + else + { + if (u_GlowChannels == 6) + { + float3 param_1 = _125.xyz; + return _f1(param_1); + } + else + { + if (u_GlowChannels == 1) + { + return _t4.x; + } + else + { + if (u_GlowChannels == 2) + { + return _t4.y; + } + else + { + if (u_GlowChannels == 3) + { + return _t4.z; + } + else + { + if (u_GlowChannels == 4) + { + return _t4.w; + } + } + } + } + } + } + return _t4.w; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float& _p0, thread const float& _p1, constant float& u_Delta) +{ + float4 _t0 = float4(0.0); + float _41 = fast::clamp(_p1, u_Delta, 1.0 - u_Delta); + float _55 = smoothstep(_41 - u_Delta, _41, _p0) - smoothstep(_41, _41 + u_Delta, _p0); + _t0.x = _55; + float _64 = u_Delta / 2.0; + if (_p0 < (_41 - _64)) + { + _t0.x = 1.0; + } + _t0.y = _55 * 0.5; + if (_p0 > (_41 + _64)) + { + _t0.y = 1.0; + } + return _t0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t5 = float4(0.0); + if (buffer.u_GlowChannels == 0) + { + float4 _t6 = u_InputTexture.sample(u_InputTextureSmplr, in.uv0); + float _207 = buffer.u_Threshold - buffer.u_Delta; + float _210 = buffer.u_Threshold + buffer.u_Delta; + float3 _237 = float3(smoothstep(_207, _210, _t6.x), smoothstep(_207, _210, _t6.y), smoothstep(_207, _210, _t6.z)); + _t5.x = _237.x; + _t5.y = _237.y; + _t5.z = _237.z; + } + else + { + float2 param = in.uv0; + float param_1 = _f3(param, u_InputTexture, u_InputTextureSmplr, buffer.u_GlowChannels); + float param_2 = buffer.u_Threshold; + _t5 = _f0(param_1, param_2, buffer.u_Delta); + } + out.o_fragColor = _t5; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/293d6f5a9a94d4e5892d2f8968a99f0b.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.frag new file mode 100644 index 0000000000000000000000000000000000000000..aa2bc92a98bc84c49a2f93add690e02d303f4d00 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.frag @@ -0,0 +1,105 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_edgeMode; + float4 u_ScreenParams; + float u_Radius; + float u_MaxRadius; + float u_Sigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float2 _f0(thread const float& _p0, thread const float& _p1, constant int& u_edgeMode) +{ + float2 _t0 = float2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr) +{ + float2 _67 = float2(1.0) / u_ScreenParams.xy; + float2 _76 = uv0 + (_67 * float2(0.0, _p0)); + float2 _t2 = _76; + float2 _83 = uv0 - (_67 * float2(0.0, _p0)); + float2 _t3 = _83; + float param = _t2.y; + float param_1 = _t3.y; + float2 _t4 = _f0(param, param_1, u_edgeMode); + return (u_InputTexture.sample(u_InputTextureSmplr, _76) * _t4.x) + (u_InputTexture.sample(u_InputTextureSmplr, _83) * _t4.y); +} + +static inline __attribute__((always_inline)) +float4 _f3(thread float4& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr, constant float& u_Radius, constant float& u_MaxRadius, constant float& u_Sigma) +{ + float4 _t5 = float4(1.0); + float4 _t6 = float4(0.0); + float _134 = fast::max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8, u_edgeMode, u_ScreenParams, uv0, u_InputTexture, u_InputTextureSmplr) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = u_InputTexture.sample(u_InputTextureSmplr, in.uv0); + float4 _238 = _f3(param, buffer.u_edgeMode, buffer.u_ScreenParams, in.uv0, u_InputTexture, u_InputTextureSmplr, buffer.u_Radius, buffer.u_MaxRadius, buffer.u_Sigma); + out.o_fragColor = _238; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/4854f390a866b96321acae596f212a75.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.frag new file mode 100644 index 0000000000000000000000000000000000000000..f65796fa60c57f3aa8f2d43e2042e5dbaa2c240b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.frag @@ -0,0 +1,655 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_ShowMode; + float u_Intensity; + int u_Combine; + int u_GlowChannels; + float3 u_ColorB; + float u_Threshold; + float3 u_ColorA; +}; + +constant float3 _1240 = {}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f5(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float _f4(thread const float3& _p0) +{ + float _203 = mix(_p0.z, _p0.y, step(_p0.z, _p0.y)); + return mix(_203, _p0.x, step(_203, _p0.x)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _67; + if (_p0 < 0.5) + { + _67 = _p1 - (((1.0 - (2.0 * _p0)) * _p1) * (1.0 - _p1)); + } + else + { + float _86; + if (_p1 < 0.25) + { + _86 = _p1 + ((((2.0 * _p0) - 1.0) * _p1) * ((((16.0 * _p1) - 12.0) * _p1) + 3.0)); + } + else + { + _86 = _p1 + (((2.0 * _p0) - 1.0) * (sqrt(_p1) - _p1)); + } + _67 = _86; + } + return _67; +} + +static inline __attribute__((always_inline)) +float3 _f1(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f0(param, param_1), _f0(param_2, param_3), _f0(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float _151; + if (_p0 < 0.5) + { + _151 = (2.0 * _p0) * _p1; + } + else + { + _151 = 1.0 - ((2.0 * (1.0 - _p0)) * (1.0 - _p1)); + } + return _151; +} + +static inline __attribute__((always_inline)) +float3 _f3(thread const float3& _p0, thread const float3& _p1) +{ + float param = _p0.x; + float param_1 = _p1.x; + float param_2 = _p0.y; + float param_3 = _p1.y; + float param_4 = _p0.z; + float param_5 = _p1.z; + return float3(_f2(param, param_1), _f2(param_2, param_3), _f2(param_4, param_5)); +} + +static inline __attribute__((always_inline)) +float _f8(thread const float3& _p0) +{ + return fast::max(_p0.x, fast::max(_p0.y, _p0.z)) - fast::min(_p0.x, fast::min(_p0.y, _p0.z)); +} + +static inline __attribute__((always_inline)) +float3 _f7(thread float3& _p0, thread const float& _p1) +{ + if (_p0.z > _p0.x) + { + _p0.y = ((_p0.y - _p0.x) * _p1) / (_p0.z - _p0.x); + _p0.z = _p1; + } + else + { + _p0.y = 0.0; + _p0.z = 0.0; + } + _p0.x = 0.0; + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f9(thread float3& _p0, thread const float& _p1) +{ + bool _343 = _p0.x <= _p0.y; + bool _351; + if (_343) + { + _351 = _p0.x <= _p0.z; + } + else + { + _351 = _343; + } + if (_351) + { + if (_p0.y <= _p0.z) + { + float3 param = _p0; + float param_1 = _p1; + float3 _365 = _f7(param, param_1); + _p0 = _365; + } + else + { + float3 param_2 = _p0.xzy; + float param_3 = _p1; + float3 _372 = _f7(param_2, param_3); + _p0 = float3(_372.x, _372.z, _372.y); + } + } + else + { + bool _380 = _p0.y <= _p0.x; + bool _388; + if (_380) + { + _388 = _p0.y <= _p0.z; + } + else + { + _388 = _380; + } + if (_388) + { + if (_p0.x <= _p0.z) + { + float3 param_4 = _p0.yxz; + float param_5 = _p1; + float3 _403 = _f7(param_4, param_5); + _p0 = float3(_403.y, _403.x, _403.z); + } + else + { + float3 param_6 = _p0.yzx; + float param_7 = _p1; + float3 _412 = _f7(param_6, param_7); + _p0 = float3(_412.z, _412.x, _412.y); + } + } + else + { + if (_p0.x <= _p0.y) + { + float3 param_8 = _p0.zxy; + float param_9 = _p1; + float3 _428 = _f7(param_8, param_9); + _p0 = float3(_428.y, _428.z, _428.x); + } + else + { + float3 param_10 = _p0.zyx; + float param_11 = _p1; + float3 _437 = _f7(param_10, param_11); + _p0 = float3(_437.z, _437.y, _437.x); + } + } + } + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f6(thread float3& _p0, thread float& _p1) +{ + float3 param = _p0; + _p0 += float3(_p1 - _f5(param)); + float3 param_1 = _p0; + _p1 = _f5(param_1); + float _243 = fast::min(_p0.x, fast::min(_p0.y, _p0.z)); + float _246 = _p0.x; + float _248 = _p0.y; + float _250 = _p0.z; + float _252 = fast::max(_246, fast::max(_248, _250)); + if (_243 < 0.0) + { + _p0 = mix(float3(_p1, _p1, _p1), _p0, float3(_p1 / (_p1 - _243))); + } + if (_252 > 1.0) + { + _p0 = mix(float3(_p1, _p1, _p1), _p0, float3((1.0 - _p1) / (_252 - _p1))); + } + return _p0; +} + +static inline __attribute__((always_inline)) +float3 _f10(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + float param_2 = _f8(param); + float3 _449 = _f9(param_1, param_2); + float3 param_3 = _p1; + float3 param_4 = _449; + float param_5 = _f5(param_3); + float3 _455 = _f6(param_4, param_5); + return _455; +} + +static inline __attribute__((always_inline)) +float3 _f11(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p0; + float3 param_1 = _p1; + float param_2 = _f8(param); + float3 _464 = _f9(param_1, param_2); + float3 param_3 = _p1; + float3 param_4 = _464; + float param_5 = _f5(param_3); + float3 _470 = _f6(param_4, param_5); + return _470; +} + +static inline __attribute__((always_inline)) +float3 _f12(thread const float3& _p0, thread const float3& _p1) +{ + float3 param = _p1; + float3 param_1 = _p0; + float param_2 = _f5(param); + float3 _479 = _f6(param_1, param_2); + return _479; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], texture2d u_BlurTexture [[texture(1)]], sampler u_InputTextureSmplr [[sampler(0)]], sampler u_BlurTextureSmplr [[sampler(1)]]) +{ + main0_out out = {}; + float4 _494 = u_InputTexture.sample(u_InputTextureSmplr, in.v_uv); + float4 _t4 = _494; + float4 _499 = u_BlurTexture.sample(u_BlurTextureSmplr, in.v_uv); + float4 _t5 = _499; + float _504 = (_t5.y * 2.0) - 1.0; + float _511 = (1.0 - abs(_504)) * _t5.y; + float _517 = step(_504, 0.0) * (0.5 - _511); + if (buffer.u_ShowMode == 1) + { + out.o_fragColor = _499 * buffer.u_Intensity; + if (buffer.u_Combine == 2) + { + out.o_fragColor = _499.xxxx * buffer.u_Intensity; + } + else + { + if (buffer.u_GlowChannels != 0) + { + out.o_fragColor = float4(float3(_511) * buffer.u_Intensity, 1.0); + } + } + return out; + } + float4 _t9 = _499; + bool _562 = buffer.u_GlowChannels != 0; + if (_562) + { + if (buffer.u_Combine == 2) + { + _t9 = _499.xxxx; + } + else + { + _t9 = float4(_511); + } + float4 _577 = _t9; + float3 _579 = _577.xyz * buffer.u_ColorB; + _t9.x = _579.x; + _t9.y = _579.y; + _t9.z = _579.z; + } + float4 _587 = _t9; + float3 _589 = _587.xyz * buffer.u_Intensity; + _t9.x = _589.x; + _t9.y = _589.y; + _t9.z = _589.z; + float4 _596 = _t9; + float3 _600 = fast::clamp(_596.xyz, float3(0.0), float3(1.0)); + _t9.x = _600.x; + _t9.y = _600.y; + _t9.z = _600.z; + float _t10 = 0.0; + if (buffer.u_GlowChannels == 1) + { + _t10 = _t4.x; + } + else + { + if (buffer.u_GlowChannels == 2) + { + _t10 = _t4.y; + } + else + { + if (buffer.u_GlowChannels == 3) + { + _t10 = _t4.z; + } + else + { + if (buffer.u_GlowChannels == 4) + { + _t10 = _t4.w; + } + else + { + if (buffer.u_GlowChannels == 5) + { + float3 param = _494.xyz; + _t10 = _f5(param); + } + else + { + if (buffer.u_GlowChannels == 6) + { + float3 param_1 = _494.xyz; + _t10 = _f4(param_1); + } + } + } + } + } + } + float4 _t11 = _494; + if (buffer.u_Combine == 1) + { + float3 _668 = _t9.xyz + _494.xyz; + _t11.x = _668.x; + _t11.y = _668.y; + _t11.z = _668.z; + } + else + { + if (buffer.u_Combine == 2) + { + float3 _684 = _t9.xyz * _494.xyz; + _t11.x = _684.x; + _t11.y = _684.y; + _t11.z = _684.z; + } + else + { + if (buffer.u_Combine == 3) + { + float3 _701 = abs(_t9.xyz - _494.xyz); + _t11.x = _701.x; + _t11.y = _701.y; + _t11.z = _701.z; + } + else + { + if (buffer.u_Combine == 4) + { + if (_562) + { + float4 _718 = _t9; + float3 _721 = _718.xyz + float3(_517); + _t9.x = _721.x; + _t9.y = _721.y; + _t9.z = _721.z; + } + float _731; + if (_t4.x < 0.5) + { + _731 = (2.0 * _t4.x) * _t9.x; + } + else + { + _731 = 1.0 - ((2.0 * (1.0 - _t4.x)) * (1.0 - _t9.x)); + } + float _754; + if (_t4.y < 0.5) + { + _754 = (2.0 * _t4.y) * _t9.y; + } + else + { + _754 = 1.0 - ((2.0 * (1.0 - _t4.y)) * (1.0 - _t9.y)); + } + float _777; + if (_t4.z < 0.5) + { + _777 = (2.0 * _t4.z) * _t9.z; + } + else + { + _777 = 1.0 - ((2.0 * (1.0 - _t4.z)) * (1.0 - _t9.z)); + } + float3 _797 = float3(_731, _754, _777); + _t11.x = _797.x; + _t11.y = _797.y; + _t11.z = _797.z; + } + else + { + if (buffer.u_Combine == 5) + { + if (_562) + { + float4 _814 = _t9; + float3 _817 = _814.xyz + float3(_517); + _t9.x = _817.x; + _t9.y = _817.y; + _t9.z = _817.z; + } + float4 _824 = _t9; + float3 _826 = _824.xyz * 2.0; + _t9.x = _826.x; + _t9.y = _826.y; + _t9.z = _826.z; + float3 _837 = fast::min(_t9.xyz, _494.xyz); + _t11.x = _837.x; + _t11.y = _837.y; + _t11.z = _837.z; + } + else + { + if (buffer.u_Combine == 6) + { + float3 _853 = fast::max(_t9.xyz, _494.xyz); + _t11.x = _853.x; + _t11.y = _853.y; + _t11.z = _853.z; + } + else + { + if (buffer.u_Combine == 7) + { + if (_562) + { + float4 _871 = _t9; + float3 _874 = _871.xyz + float3(_517); + _t9.x = _874.x; + _t9.y = _874.y; + _t9.z = _874.z; + } + float3 param_2 = _t9.xyz; + float3 param_3 = _494.xyz; + float3 _887 = _f1(param_2, param_3); + _t11.x = _887.x; + _t11.y = _887.y; + _t11.z = _887.z; + } + else + { + if (buffer.u_Combine == 8) + { + if (_562) + { + float4 _905 = _t9; + float3 _908 = _905.xyz + float3(_517); + _t9.x = _908.x; + _t9.y = _908.y; + _t9.z = _908.z; + } + float3 param_4 = _t9.xyz; + float3 param_5 = _494.xyz; + float3 _921 = _f3(param_4, param_5); + _t11.x = _921.x; + _t11.y = _921.y; + _t11.z = _921.z; + } + else + { + if (buffer.u_Combine == 9) + { + if (buffer.u_GlowChannels == 0) + { + _t11.x = _t9.xyz.x; + _t11.y = _t9.xyz.y; + _t11.z = _t9.xyz.z; + } + else + { + float3 _951 = _494.xyz; + float3 _974 = mix(mix(_t9.xyz, (_t9.xyz + _951) - (_t9.xyz * _951), float3(fast::clamp(_t9.x, 0.0, 1.0))), _951, float3(fast::clamp(_517 * 2.0, 0.0, 1.0))); + _t11.x = _974.x; + _t11.y = _974.y; + _t11.z = _974.z; + } + } + else + { + if (buffer.u_Combine == 10) + { + if (buffer.u_GlowChannels == 0) + { + float3 param_6 = _t9.xyz; + float3 param_7 = _494.xyz; + float3 _997 = _f10(param_6, param_7); + _t11.x = _997.x; + _t11.y = _997.y; + _t11.z = _997.z; + } + else + { + float4 _1006 = _t9; + float3 _1009 = _1006.xyz + float3(_517); + _t9.x = _1009.x; + _t9.y = _1009.y; + _t9.z = _1009.z; + float3 param_8 = _t9.xyz; + float3 _1021 = _494.xyz; + float3 param_9 = _1021; + float3 _1030 = mix(_f10(param_8, param_9), _1021, float3(fast::clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1030.x; + _t11.y = _1030.y; + _t11.z = _1030.z; + } + } + else + { + if (buffer.u_Combine == 11) + { + if (buffer.u_GlowChannels == 0) + { + float3 param_10 = _t9.xyz; + float3 param_11 = _494.xyz; + float3 _1053 = _f11(param_10, param_11); + _t11.x = _1053.x; + _t11.y = _1053.y; + _t11.z = _1053.z; + } + else + { + float4 _1062 = _t9; + float3 _1065 = _1062.xyz + float3(_517); + _t9.x = _1065.x; + _t9.y = _1065.y; + _t9.z = _1065.z; + float3 param_12 = _t9.xyz; + float3 _1077 = _494.xyz; + float3 param_13 = _1077; + float3 _1086 = mix(_f11(param_12, param_13), _1077, float3(fast::clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1086.x; + _t11.y = _1086.y; + _t11.z = _1086.z; + } + } + else + { + if (buffer.u_Combine == 12) + { + if (buffer.u_GlowChannels == 0) + { + float3 param_14 = _t9.xyz; + float3 param_15 = _494.xyz; + float3 _1109 = _f12(param_14, param_15); + _t11.x = _1109.x; + _t11.y = _1109.y; + _t11.z = _1109.z; + } + else + { + float4 _1118 = _t9; + float3 _1121 = _1118.xyz + float3(_517); + _t9.x = _1121.x; + _t9.y = _1121.y; + _t9.z = _1121.z; + float3 param_16 = _t9.xyz; + float3 _1133 = _494.xyz; + float3 param_17 = _1133; + float3 _1142 = mix(_f12(param_16, param_17), _1133, float3(fast::clamp(_t9.x * 2.0, 0.0, 1.0))); + _t11.x = _1142.x; + _t11.y = _1142.y; + _t11.z = _1142.z; + } + } + else + { + float3 _1153 = _494.xyz; + float3 _1160 = (_t9.xyz + _1153) - (_t9.xyz * _1153); + _t11.x = _1160.x; + _t11.y = _1160.y; + _t11.z = _1160.z; + } + } + } + } + } + } + } + } + } + } + } + } + if (_562) + { + if (_t10 > buffer.u_Threshold) + { + float4 _1181 = _t11; + float3 _1183 = _1181.xyz + (buffer.u_ColorA * _t10); + _t11.x = _1183.x; + _t11.y = _1183.y; + _t11.z = _1183.z; + } + if (((((((((buffer.u_Combine == 2) || (buffer.u_Combine == 4)) || (buffer.u_Combine == 5)) || (buffer.u_Combine == 7)) || (buffer.u_Combine == 8)) || (buffer.u_Combine == 9)) || (buffer.u_Combine == 10)) || (buffer.u_Combine == 11)) || (buffer.u_Combine == 12)) + { + _t11 = mix(_494, _t11, float4(fast::clamp(buffer.u_Intensity, 0.0, 1.0))); + } + } + float4 _1224 = _t11; + float _1227 = _t11.w; + float3 _1230 = fast::clamp(_1224.xyz, float3(0.0), float3(_1227)); + _t11.x = _1230.x; + _t11.y = _1230.y; + _t11.z = _1230.z; + out.o_fragColor = _t11; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/a068bda12b29d552633e491beca8b097.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.frag new file mode 100644 index 0000000000000000000000000000000000000000..205b251012432512401c331e7f11f1f3d6fd51b0 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.frag @@ -0,0 +1,105 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_edgeMode; + float4 u_ScreenParams; + float u_Radius; + float u_MaxRadius; + float u_Sigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float2 _f0(thread const float& _p0, thread const float& _p1, constant int& u_edgeMode) +{ + float2 _t0 = float2(1.0); + if (u_edgeMode == 0) + { + _t0.x = step(0.0, _p0) * step(_p0, 1.0); + _t0.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr) +{ + float2 _67 = float2(1.0) / u_ScreenParams.xy; + float2 _76 = uv0 + (_67 * float2(_p0, 0.0)); + float2 _t2 = _76; + float2 _83 = uv0 - (_67 * float2(_p0, 0.0)); + float2 _t3 = _83; + float param = _t2.x; + float param_1 = _t3.x; + float2 _t4 = _f0(param, param_1, u_edgeMode); + return (u_InputTexture.sample(u_InputTextureSmplr, _76) * _t4.x) + (u_InputTexture.sample(u_InputTextureSmplr, _83) * _t4.y); +} + +static inline __attribute__((always_inline)) +float4 _f3(thread float4& _p0, constant int& u_edgeMode, constant float4& u_ScreenParams, thread float2& uv0, texture2d u_InputTexture, sampler u_InputTextureSmplr, constant float& u_Radius, constant float& u_MaxRadius, constant float& u_Sigma) +{ + float4 _t5 = float4(1.0); + float4 _t6 = float4(0.0); + float _134 = fast::max(1.0, u_Radius / u_MaxRadius); + float _t9 = 1.0; + for (float _t10 = 1.0; _t10 <= 128.0; _t10 += 1.0) + { + if (_t9 > 128.0) + { + break; + } + if ((_t9 > (u_MaxRadius * _134)) || (!(_t9 <= u_Radius))) + { + break; + } + float param = _t9; + float param_1 = u_Sigma; + _t6.x = step(_t9, u_Radius) * _f2(param, param_1); + float param_2 = _t9; + float param_3 = u_Sigma; + _t6.y = step(_t9, u_Radius) * _f2(param_2, param_3); + float param_4 = _t9; + float param_5 = u_Sigma; + _t6.z = step(_t9, u_Radius) * _f2(param_4, param_5); + float param_6 = _t9; + float param_7 = u_Sigma; + _t6.w = step(_t9, u_Radius) * _f2(param_6, param_7); + float param_8 = _t9; + _p0 += (_f1(param_8, u_edgeMode, u_ScreenParams, uv0, u_InputTexture, u_InputTextureSmplr) * _t6); + _t5 += (_t6 * 2.0); + _t9 += _134; + } + _p0 /= _t5; + return _p0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_InputTexture [[texture(0)]], sampler u_InputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = u_InputTexture.sample(u_InputTextureSmplr, in.uv0); + float4 _238 = _f3(param, buffer.u_edgeMode, buffer.u_ScreenParams, in.uv0, u_InputTexture, u_InputTextureSmplr, buffer.u_Radius, buffer.u_MaxRadius, buffer.u_Sigma); + out.o_fragColor = _238; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBCCGlowOBS/xshader/shaderLib/shaderMetal/c94c7a07a0da4a8023816dd0078a1657.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/js/customMask.js b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/js/customMask.js new file mode 100644 index 0000000000000000000000000000000000000000..a65cc4aacc571a2ffbb05204ac82c76a80408d4c --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/js/customMask.js @@ -0,0 +1,91 @@ +const Amaz = effect.Amaz; +const cv = Amaz.JSWrapCV; +const SCRIPT_NAME = 'customMask'; +/** + * System script is NOT recommended to be used anymore. + * Avoid using system script unless you really have to. + */ +class customMask { + constructor() { + this.name = SCRIPT_NAME; + this.dis = 7 + this.curTime = 0 + } + + /** onInit is called before onStart(). */ + onInit() { } + + /** onStart is called before the first onUpdate() call. */ + onStart() { + this.lua = this.entity.getComponent('ScriptComponent'); + this.cam = this.entity.searchEntity("customMaskCam"); + this.mat = this.entity.searchEntity("customMask").getComponent("MeshRenderer").material; + } + + convertContours(contours, rw, rh, limit) { + let result = new Amaz.Vec2Vector(); + L_all: + for (let i = 0; i < contours.length; ++i) { + let contour = contours[i]; + let convertedContour = new Amaz.Vec2Vector(); + Amaz.AmazingUtil.arrayBufferToPrimitiveVector(contour, convertedContour); + for (let j = 0; j < convertedContour.size(); ++j) { + let point = convertedContour.get(j); + result.pushBack(new Amaz.Vector2f(point.x * rw, point.y * rh)); + if (result.size() >= limit) + break L_all; + } + } + return result; + } + + /** onUpdate is called once every frame. */ + onUpdate(deltaTime) { + if (!this.cam.visible) + return; + + let prop = this.lua.properties + if (!prop.has("customMaskTex")) + return; + + let resource = prop.get("customMaskTex"); + let image = resource.image; + if (image == null) + image = resource.getImage(); + if (image == null) + return; + + let size = 80 + if (prop.has("maskSize")) + size = Math.min(prop.get("maskSize"), 80); + + let mat = cv.Mat(image); + cv.resize(mat, mat, [80, 80]) + cv.cvtColor(mat, mat, 0xb); + cv.threshold(mat, mat, 125, 255, 0) + let elem = cv.getStructuringElement(2, [4, 4]); + cv.erode(mat, mat, elem); + if (size < 80) + cv.resize(mat, mat, [size, size]); + let contours = new Array(); + cv.findContours(mat, contours, 2, 1); + let convertedContours = this.convertContours(contours, 1.0 / mat.cols, 1.0 / mat.rows, 500); + this.mat.setVec2Vector("u_contours", convertedContours); + this.mat.setInt("u_pointCount", convertedContours.size()); + + // Amaz.LOGE("", `maskSize: ${size}`); + // Amaz.LOGE("", `contoursPoints: ${convertedContours.size()}`); + } + + /** onLateUpdate is called once every frame after onUpdate(). */ + onLateUpdate(deltaTime) { } + + /** onEvent is called when an event arrives. */ + onEvent(event) { + } + /** onDestroy is called when this script instance is destroyed. */ + onDestroy() { } + +} + +exports.customMask = customMask; \ No newline at end of file diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/lua/LumiBokehBlur.lua b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/lua/LumiBokehBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..51b808a5d05478faab9a76f0dc1dd44a68e1b39c --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/lua/LumiBokehBlur.lua @@ -0,0 +1,302 @@ + +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false + +local exports = exports or {} +local LumiBokehBlur = LumiBokehBlur or {} +---@class LumiBokehBlur: ScriptComponent [UI(Display="The Circle Bokeh")] +---@field bokehMode string [UI(Option={"Circle", "Heart", "Polygon","Star","CustomMask"})] +---@field scale number [UI(Range={0, 80}, Drag)] +---@field scaleX number [UI(Range={0, 1}, Drag)] +---@field scaleY number [UI(Range={0, 1}, Drag)] +---@field regionIns number [UI(Range={0., 1}, Drag)] +---@field lightIns number [UI(Range={0, 6}, Drag)] +---@field darkIns number [UI(Range={0, 4}, Drag)] +---@field quality number [UI(Range={0., 1}, Drag)] +---@field lineNum int [UI(Range={3, 8}, Slider)] +---@field shapeIns number [UI(Range={0.2, 1}, Drag)] +---@field angle number [UI(Range={-360, 360}, Drag)] +---@field customMaskTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local BokehModeName = { + "Circle", "Heart", "Polygon","Star","CustomMask" +} +setmetatable(BokehModeName, {__index = function(_, _) return BokehModeName[1] end}) + + +LumiBokehBlur.__index = LumiBokehBlur +function LumiBokehBlur.new(construct, ...) + local self = setmetatable({}, LumiBokehBlur) + if construct and LumiBokehBlur.constructor then LumiBokehBlur.constructor(self, ...) end + self.bokehMode = "Circle" + self.scale = 20 + self.scaleX = 1 + self.scaleY = 1 + self.regionIns = 0.5 + self.lightIns = 1 + self.quality = 1 + self.darkIns = 0. + self.shapeIns = 1 + + -- polygon extra param + self.angle = 0 + self.lineNum = 5 + self.customMaskTex = nil + self.InputTex = nil + self.OutputTex = nil + + self.MAX_SCALE = 80 + + return self +end + +function LumiBokehBlur:setEffectAttr(key, value, comp) + if key == "bokehMode" then + value = BokehModeName[value + 1] + end + self[key] = value + comp.properties:set(key, value) +end + +function LumiBokehBlur:onStart(comp) + self.interface = comp.properties + + self.bufBlur0 = comp.entity:searchEntity("blur0Cam"):getComponent("Camera").renderTexture + self.matBlur0 = comp.entity:searchEntity("blur0"):getComponent("MeshRenderer").material + + self.bufBlur1 = comp.entity:searchEntity("blur1Cam"):getComponent("Camera").renderTexture + self.matBlur1 = comp.entity:searchEntity("blur1"):getComponent("MeshRenderer").material + + self.objCircle = comp.entity:searchEntity("circleCam") + self.matCircle = comp.entity:searchEntity("circle"):getComponent("MeshRenderer").material + + self.objPolygon = comp.entity:searchEntity("polygonCam") + self.matPolygon = comp.entity:searchEntity("polygon"):getComponent("MeshRenderer").material + + self.objStar = comp.entity:searchEntity("starCam") + self.matStar = comp.entity:searchEntity("star"):getComponent("MeshRenderer").material + + self.objHeart = comp.entity:searchEntity("heartCam") + self.matHeart = comp.entity:searchEntity("heart"):getComponent("MeshRenderer").material + + self.objMask = comp.entity:searchEntity("getminMaskTexCam") + self.matMask = comp.entity:searchEntity("getminMaskTex"):getComponent("MeshRenderer").material + + self.objCustom = comp.entity:searchEntity("customMaskCam") + self.matCustom = comp.entity:searchEntity("customMask"):getComponent("MeshRenderer").material + + self.bufMask = self.objMask:getComponent("Camera").renderTexture + self.bufBokeh = self.objCircle:getComponent("Camera").renderTexture + + self.camOutput = comp.entity:searchEntity("in2outCam"):getComponent("Camera") +end + +function LumiBokehBlur:onUpdate(comp, dt) + if not self.OutputTex then return end + self.camOutput.renderTexture = self.OutputTex + + self.canvasW = self.OutputTex.width + self.canvasH = self.OutputTex.height + self.designScale = math.min(self.canvasW, self.canvasH) / 720 + self.realSize = self.scale * self.designScale + self.canvasScale = math.min(self.mix(6, 16, self.quality) / math.max(self.realSize, 1), 1) + self.scaledCanvasW = self.canvasW * self.canvasScale + self.scaledCanvasH = self.canvasH * self.canvasScale + self.scaledSize = self.realSize * self.canvasScale + + --Amaz.LOGE("", string.format("scaledCanvasW: %.3f", self.scaledCanvasW)) + --Amaz.LOGE("", string.format("scaledCanvasH: %.3f", self.scaledCanvasH)) + --Amaz.LOGE("", string.format("realSize: %.3f", self.realSize)) + --Amaz.LOGE("", string.format("scaledSize: %.3f", self.scaledSize)) + + self.objCircle.visible = false + self.objHeart.visible = false + self.objPolygon.visible = false + self.objStar.visible = false + self.objMask.visible = false + self.objCustom.visible = false + + self:updateBlur() + + if self.bokehMode == 'Heart' then + self:updateHeart() + elseif self.bokehMode == 'Polygon' then + self:updatePolygon() + elseif self.bokehMode == 'Star' then + self:updateStar() + elseif self.bokehMode == 'CustomMask' then + self:updateCustom() + else + self:updateCircle() + end +end + +function LumiBokehBlur:updateBlur() + self.bufBlur0.width = math.ceil(self.scaledCanvasW) + self.bufBlur0.height = math.ceil(self.scaledCanvasH) + self.bufBlur1.width = math.ceil(self.scaledCanvasW) + self.bufBlur1.height = math.ceil(self.scaledCanvasH) + + self.matBlur0:setTex("u_inputTex", self.InputTex) + + local intensity = self.scale / self.MAX_SCALE + local radius = 22 * self.designScale * self.canvasScale * math.pow(intensity, 0.35) * 0.7 + local samples = math.ceil(radius) + self.matBlur0:setInt("u_samples", samples) + self.matBlur0:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matBlur1:setInt("u_samples", samples) + self.matBlur1:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matBlur1:setFloat("u_intensity", intensity) + self.matBlur1:setFloat("u_darkIns", self.darkIns) +end + +function LumiBokehBlur:updateCircle() + self.objCircle.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.80) + local samplesEdge = math.ceil(2 * math.pi * self.scaledSize / sampleScale * 1.00) + self.matCircle:setInt("u_samplesCore", samplesCore) + self.matCircle:setInt("u_samplesEdge", samplesEdge) + self.matCircle:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matCircle:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matCircle:setFloat("u_radius", self.scaledSize) + self.matCircle:setFloat("u_regionIns", self.regionIns) + self.matCircle:setFloat("u_lightIns", self.lightIns) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur.getPolygonAngle0(lineNum, angle0) + if lineNum == 3 then + return math.rad(angle0 - 90) + elseif lineNum == 4 then + return math.rad(angle0 - 90) + elseif lineNum == 5 then + return math.rad(angle0 - 90) + elseif lineNum == 6 then + return math.rad(angle0 - 90) + elseif lineNum == 7 then + return math.rad(angle0 - 90) + else + return math.rad(angle0 - 90) + end +end +function LumiBokehBlur:updatePolygon() + self.objPolygon.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.75) + local samplesEdge = math.ceil(2 * math.pi * self.scaledSize / sampleScale * 1.00) + self.matPolygon:setInt("u_samplesCore", samplesCore) + self.matPolygon:setInt("u_samplesEdge", samplesEdge) + self.matPolygon:setInt("u_lineNum", self.lineNum) + self.matPolygon:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matPolygon:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matPolygon:setFloat("u_radius", self.scaledSize) + self.matPolygon:setFloat("u_angle0", self.getPolygonAngle0(self.lineNum, self.angle)) + self.matPolygon:setFloat("u_regionIns", self.regionIns) + self.matPolygon:setFloat("u_lightIns", self.lightIns) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur.getStarAngle0(lineNum, angle0) + if lineNum == 3 then + return math.rad(angle0 + 90) + elseif lineNum == 4 then + return math.rad(angle0 + 90) + elseif lineNum == 5 then + return math.rad(angle0 + 90) + elseif lineNum == 6 then + return math.rad(angle0 + 60) + elseif lineNum == 7 then + return math.rad(angle0 + 90) + else + return math.rad(angle0 + 22.5) + end +end +function LumiBokehBlur:updateStar() + self.objStar.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.80) + local samplesEdge = math.ceil(2 * math.pi * self.scaledSize / sampleScale * 4.00) + self.matStar:setInt("u_samplesCore", samplesCore) + self.matStar:setInt("u_samplesEdge", samplesEdge) + self.matStar:setInt("u_lineNum", self.lineNum) + self.matStar:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matStar:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matStar:setFloat("u_radius", self.scaledSize) + self.matStar:setFloat("u_angle0", self.getStarAngle0(self.lineNum, self.angle)) + self.matStar:setFloat("u_regionIns", self.regionIns) + self.matStar:setFloat("u_lightIns", self.lightIns) + self.matStar:setFloat('u_shapeIns', self.shapeIns) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur:updateHeart() + self.objHeart.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local sampleScale = self.mix(2.5, 1, self.scale / self.MAX_SCALE) + local samplesCore = math.ceil(math.pi * self.scaledSize * self.scaledSize / sampleScale * 0.80) + local samplesEdge = self.mix(90, 360, self.quality)--math.ceil(2 * math.pi * self.scaledSize / sampleScale * 4.00) + self.matHeart:setInt("u_samplesCore", samplesCore) + self.matHeart:setInt("u_samplesEdge", samplesEdge) + self.matHeart:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matHeart:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY * 0.8)) + self.matHeart:setFloat("u_radius", self.scaledSize) + self.matHeart:setFloat("u_regionIns", self.regionIns) + self.matHeart:setFloat("u_lightIns", self.lightIns) + self.matHeart:setFloat("u_shapeIns", self.shapeIns) + self.matHeart:setFloat("u_angle0", math.rad(self.angle + 180)) + + --Amaz.LOGE("", string.format("samplesCore: %d", samplesCore)) + --Amaz.LOGE("", string.format("samplesEdge: %d", samplesEdge)) +end + +function LumiBokehBlur:updateCustom() + self.objMask.visible = true + self.objCustom.visible = true + self.bufBokeh.width = math.ceil(self.scaledCanvasW) + self.bufBokeh.height = math.ceil(self.scaledCanvasH) + + local maskSize = self.mix(self.scaledSize, self.scale, self.quality) * 2 + local maskSizeI = math.max(math.ceil(maskSize), 8) + if self.customMaskTex then + self.bufMask.width = self.MAX_SCALE * 2 + self.bufMask.height = self.MAX_SCALE * 2 + self.interface:set("maskSize", maskSizeI) + self.matMask:setTex("u_maskTex", self.customMaskTex) + end + + self.matCustom:setVec2("u_screenSize", Amaz.Vector2f(self.scaledCanvasW, self.scaledCanvasH)) + self.matCustom:setVec2("u_scale", Amaz.Vector2f(self.scaleX, self.scaleY)) + self.matCustom:setInt("u_samples", math.ceil(self.scaledSize * 0.7)) + self.matCustom:setFloat("u_radius", self.scaledSize) + self.matCustom:setFloat("u_regionIns", self.regionIns) + self.matCustom:setFloat("u_lightIns", self.lightIns) + self.matCustom:setFloat("u_angle0", math.rad(self.angle + 180)) + + --Amaz.LOGE("", string.format("maskSize: %d", maskSizeI)) +end + +function LumiBokehBlur.mix(a, b, t) + return a + (b - a) * t +end + +exports.LumiBokehBlur = LumiBokehBlur +return exports diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.frag new file mode 100644 index 0000000000000000000000000000000000000000..eaae12db535b03089ca797f59cb5b7e8b4f09a0d --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.frag @@ -0,0 +1,12 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_inputTex; + +varying vec2 v_uv; + +void main() +{ + gl_FragData[0] = texture2D(u_inputTex, v_uv); +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/103fe4fa2cd41b88b7928e3c1e99a21c.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag new file mode 100644 index 0000000000000000000000000000000000000000..962259ec4436781b043ce74eab144a92e4d284df --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag @@ -0,0 +1,85 @@ +precision highp float; +precision highp int; + +uniform mediump int u_samples; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; +uniform mediump sampler2D u_noiseTex; +uniform mediump sampler2D u_filterTex; +uniform float u_intensity; +uniform float u_darkIns; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, vec2 _p2) +{ + float param = 0.0; + float param_1 = 4.0; + float _66 = _f0(param, param_1); + float _t1 = _66; + vec2 _t2 = vec2(1.0) / _p2; + vec4 _t3 = texture2D(_p0, _p1) * _66; + mediump float _83 = float(u_samples); + for (mediump int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _83) * 15.0; + float param_3 = 4.0; + float _108 = _f0(param_2, param_3); + vec2 _117 = vec2(_t2.x * float(_t5), 0.0); + _t3 = (_t3 + (texture2D(_p0, _p1 + _117) * _108)) + (texture2D(_p0, _p1 - _117) * _108); + _t1 += (_108 + _108); + } + return _t3 / vec4(_t1); +} + +vec3 _f2(vec4 _p0) +{ + return mix(vec3(0.0), _p0.xyz / vec3(_p0.w + 9.9999997473787516355514526367188e-05), vec3(step(9.9999997473787516355514526367188e-05, _p0.w))); +} + +vec3 _f3(mediump sampler2D _p0, inout vec3 _p1) +{ + _p1 *= 63.0; + vec2 _178 = vec2(floor(_p1.z), ceil(_p1.z)); + vec2 _t10 = _178; + vec2 _183 = floor(_178 * 0.125); + vec4 _216 = (vec4(_178 - (_183 * 8.0), _183).xzyw * 0.125) + vec4(((_p1.xy + vec2(0.5)) * 0.001953125).xyxy); + return mix(texture2D(_p0, _216.xy).xyz, texture2D(_p0, _216.zw).xyz, vec3(_p1.z - _t10.x)); +} + +vec4 _f4(vec4 _p0, mediump sampler2D _p1, float _p2) +{ + vec4 param = _p0; + vec3 _242 = _f2(param); + vec3 _t17 = _242; + vec3 param_1 = _242; + vec3 _246 = _f3(_p1, param_1); + vec3 _247 = _t17; + vec3 _251 = mix(_247, _246, vec3(_p2)); + _t17 = _251; + return vec4(_251, 1.0) * _p0.w; +} + +void main() +{ + vec2 param = v_uv; + vec2 param_1 = u_screenSize; + vec4 _272 = _f1(u_inputTex, param, param_1); + vec4 _t19 = _272; + vec4 param_2 = _272; + float param_3 = (0.5 * u_intensity) * u_darkIns; + vec4 _313 = _f4(param_2, u_filterTex, param_3); + _t19 = _313; + vec3 _315 = _313.xyz; + vec3 _330 = mix(_315, _315 * ((texture2D(u_noiseTex, fract(((v_uv * u_screenSize) / vec2(min(u_screenSize.x, u_screenSize.y))) * 2.0)).x * 1.0) + 0.0), vec3(((dot(_272.xyz, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)) * 0.100000001490116119384765625) * u_intensity) * u_darkIns)); + _t19.x = _330.x; + _t19.y = _330.y; + _t19.z = _330.z; + gl_FragData[0] = _t19; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.frag new file mode 100644 index 0000000000000000000000000000000000000000..26c304d1b1ab1af74132ae1bca2e92a1b8556d71 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.frag @@ -0,0 +1,95 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform float u_angle0; +uniform mediump int u_lineNum; +uniform mediump int u_samplesCore; +uniform float u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return mat2(vec2(_36, -_33), vec2(_33, _36)); +} + +vec4 _f1(vec4 _p0) +{ + vec4 _52 = _p0 * _p0; + vec4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f2(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _84 = vec2(1.0) / _p3; + vec2 _88 = _p1 * _p3; + vec4 _t10 = vec4(0.0); + vec4 _t11 = vec4(0.0); + vec4 _t12 = vec4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + vec2 _t15 = vec2(1.0, 0.0); + float param = 2.3999631404876708984375; + mat2 _t16 = _f0(param); + mediump float _111 = 6.283185482025146484375 / float(u_lineNum); + float _115 = _111 * 0.5; + float _118 = cos(_115); + for (mediump int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _139 = _t13; + float _148 = _118 / cos(mod(_139, _111) - _115); + mediump vec4 _170 = texture2D(_p0, (_88 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _148))) * _84); + vec4 param_1 = _170; + vec4 _180 = _f1(param_1) * ((u_regionIns * _148) * _148); + _t10 = max(_t10, _170 * _80); + _t11 += (_170 * _180); + _t13 += _t14; + _t12 += _180; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + mediump float _207 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _207; + _t15 = vec2(_p2, 0.0); + float param_2 = _207; + _t16 = _f0(param_2); + for (mediump int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + mediump vec4 _252 = texture2D(_p0, (_88 + ((_t15 * u_scale) * (_118 / cos(mod(_t13, _111) - _115)))) * _84); + vec4 param_3 = _252; + vec4 _256 = _f1(param_3); + _t10 = max(_t10, _252); + _t11 += (_252 * _256); + _t13 += _t14; + _t12 += _256; + _t15 = _t16 * _t15; + } + vec4 _282 = clamp(_t11 / _t12, vec4(0.0), vec4(1.0)); + return vec4(mix(_282, _t10, clamp(_282 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f2(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/62098be95c32361124a4da28939149f9.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..fee6b6590912543f30327f03666dea9d12bf61b6 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.frag @@ -0,0 +1,75 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform mediump int u_samplesCore; +uniform vec2 u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +vec4 _f0(vec4 _p0) +{ + vec4 _29 = _p0 * _p0; + vec4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _66 = vec2(1.0) / _p3; + vec2 _70 = _p1 * _p3; + vec2 _t10 = vec2(1.0, 0.0); + mat2 _t11 = mat2(vec2(-0.737368881702423095703125, -0.675490319728851318359375), vec2(0.675490319728851318359375, -0.737368881702423095703125)); + vec4 _t12 = vec4(0.0); + vec4 _t13 = vec4(0.0); + vec4 _t14 = vec4(0.0); + for (mediump int _t15 = 0; _t15 <= u_samplesCore; _t15++) + { + mediump vec4 _130 = texture2D(_p0, (_70 + ((_t10 * u_scale) * (sqrt(float(_t15) / float(u_samplesCore)) * _p2))) * _66); + vec4 param = _130; + vec4 _136 = _f0(param) * u_regionIns; + _t12 = max(_t12, _130 * _58); + _t13 += (_130 * _136); + _t14 += _136; + _t10 = _t11 * _t10; + } + mediump float _161 = 6.283185482025146484375 / float(u_samplesEdge); + float _163 = cos(_161); + float _165 = sin(_161); + _t10 = vec2(_p2, 0.0); + _t11 = mat2(vec2(_163, -_165), vec2(_165, _163)); + for (mediump int _t22 = 0; _t22 < u_samplesEdge; _t22++) + { + mediump vec4 _196 = texture2D(_p0, (_70 + (_t10 * u_scale)) * _66); + vec4 param_1 = _196; + vec4 _200 = _f0(param_1); + _t12 = max(_t12, _196); + _t13 += (_196 * _200); + _t14 += _200; + _t10 = _t11 * _t10; + } + vec4 _223 = clamp(_t13 / _t14, vec4(0.0), vec4(1.0)); + return vec4(mix(_223, _t12, clamp(_223 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f1(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/868e1e61a1297466576af58f026175ed.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.frag new file mode 100644 index 0000000000000000000000000000000000000000..c1bf551f43d9a993f7cbbe249baded2b3095d1b1 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.frag @@ -0,0 +1,23 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D u_maskTex; + +varying vec2 v_uv; + +void main() +{ + float _t0 = min(texture2D(u_maskTex, v_uv).x, 99.0); + for (mediump int _t2 = -1; _t2 <= 1; _t2++) + { + for (mediump int _t3 = -1; _t3 <= 1; _t3++) + { + _t0 = min(texture2D(u_maskTex, v_uv + (vec2(float(_t2), float(_t3)) * vec2(0.014999999664723873138427734375))).x, _t0); + } + } + float _79 = _t0; + float _111 = min(texture2D(u_maskTex, v_uv + vec2(0.0, -0.02999999932944774627685546875)).x, min(texture2D(u_maskTex, v_uv + vec2(0.0, 0.02999999932944774627685546875)).x, min(texture2D(u_maskTex, v_uv + vec2(0.02999999932944774627685546875, 0.0)).x, min(texture2D(u_maskTex, v_uv + vec2(-0.02999999932944774627685546875, 0.0)).x, _79)))); + _t0 = _111; + gl_FragData[0] = vec4(_111, _111, _111, 1.0); +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.vert new file mode 100644 index 0000000000000000000000000000000000000000..7fa9659f09c8b43c42467d693d3e1b5ba52b398a --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/c9c77ccd73acc8e37602b524fa0fc7d8.vert @@ -0,0 +1,11 @@ + +attribute vec3 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = vec4(a_position, 1.0); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.frag new file mode 100644 index 0000000000000000000000000000000000000000..692c6a505159d310a919fb855a1e2f1f35a25339 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.frag @@ -0,0 +1,107 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform mediump int u_samples; +uniform float u_angle0; +uniform vec2 u_scale; +uniform mediump int u_pointCount; +uniform vec2 u_contours[500]; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform mediump sampler2D u_maskTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _40 = sin(_p0); + float _43 = cos(_p0); + return mat2(vec2(_43, -_40), vec2(_40, _43)); +} + +float _f1(float _p0, float _p1, float _p2) +{ + return (_p2 - _p0) / (_p1 - _p0); +} + +vec4 _f2(vec4 _p0) +{ + vec4 _68 = _p0 * _p0; + vec4 _72 = _68 * _68; + return (((_72 * _72) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f3(mediump sampler2D _p0, mediump sampler2D _p1, vec2 _p2, float _p3, vec2 _p4) +{ + float _96 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _100 = vec2(1.0) / _p4; + vec2 _104 = _p2 * _p4; + mediump float _110 = float(u_samples); + float _114 = _p3 / _110; + vec4 _t12 = vec4(0.0); + vec4 _t13 = vec4(0.0); + vec4 _t14 = vec4(0.0); + float param = u_angle0; + mat2 _124 = _f0(param); + mediump int _128 = -u_samples; + for (mediump int _t16 = _128; _t16 <= u_samples; _t16++) + { + mediump float _140 = float(_t16); + float _143 = -_110; + float param_1 = _143; + float param_2 = _110; + float param_3 = _140; + float _149 = _f1(param_1, param_2, param_3); + for (mediump int _t19 = _128; _t19 <= u_samples; _t19++) + { + mediump float _163 = float(_t19); + float param_4 = _143; + float param_5 = _110; + float param_6 = _163; + if (0.5 > texture2D(_p1, vec2(_149, _f1(param_4, param_5, param_6))).x) + { + continue; + } + mediump vec4 _208 = texture2D(_p0, (_104 + (_124 * ((vec2(_140, _163) * u_scale) * _114))) * _100); + vec4 param_7 = _208; + vec4 _214 = _f2(param_7) * u_regionIns; + _t12 = max(_t12, _208 * _96); + _t13 += (_208 * _214); + _t14 += _214; + } + } + for (mediump int _t26 = 0; _t26 < 500; _t26++) + { + if (_t26 >= u_pointCount) + { + break; + } + mediump vec4 _281 = texture2D(_p0, (_104 + (_124 * ((((u_contours[_t26] * 2.0) - vec2(1.0)) * u_scale) * _p3))) * _100); + vec4 param_8 = _281; + vec4 _285 = _f2(param_8); + _t12 = max(_t12, _281); + _t13 += (_281 * _285); + _t14 += _285; + } + vec4 _305 = clamp(_t13 / _t14, vec4(0.0), vec4(1.0)); + return vec4(mix(_305, _t12, clamp(_305 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f3(u_inputTex, u_maskTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/d0e14dc2bd079d4169a342ccb3aa77ef.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.frag new file mode 100644 index 0000000000000000000000000000000000000000..b4763820a533713750b1ed32c888c296f3cc222b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.frag @@ -0,0 +1,107 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform float u_angle0; +uniform mediump int u_samplesCore; +uniform vec2 u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +mat2 _f0(float _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return mat2(vec2(_36, -_33), vec2(_33, _36)); +} + +vec4 _f1(vec4 _p0) +{ + vec4 _52 = _p0 * _p0; + vec4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f2(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _89 = vec2(1.0) / _p3; + vec2 _93 = _p1 * _p3; + float param = 0.00999999977648258209228515625; + vec2 _t11 = _f0(param) * vec2(1.0, 0.0); + float param_1 = 2.3999631404876708984375; + mat2 _t12 = _f0(param_1); + float param_2 = u_angle0; + mat2 _109 = _f0(param_2); + vec4 _t14 = vec4(0.0); + vec4 _t15 = vec4(0.0); + vec4 _t16 = vec4(0.0); + mediump int _t17 = 0; + for (;;) + { + mediump float _128 = float(u_samplesCore); + mediump float _130 = _128 * 0.0500000007450580596923828125; + mediump int _131 = int(_130); + mediump int _132 = u_samplesCore - _131; + if (_t17 <= _132) + { + float _154 = abs(_t11.y * 8.659999847412109375); + float _159 = abs(_t11.x * 8.659999847412109375); + float _161 = 2.2999999523162841796875 * sqrt(_159); + mediump vec4 _219 = texture2D(_p0, (_93 + (_109 * ((_t11 * (sqrt(float(_t17) / _128) * _p2)) * vec2(u_scale.x, u_scale.y * (mix(((_154 - _161) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _159))) + 3.0, (_154 + _161) - 3.0, step(0.0, _t11.y)) / (_154 + 1.0000000133514319600180897396058e-10)))))) * _89); + vec4 param_3 = _219; + vec4 _227 = _f1(param_3) * (u_regionIns * 2.0); + _t14 = max(_t14, _219 * _80); + _t15 += (_219 * _227); + _t16 += _227; + _t11 = _t12 * _t11; + _t17++; + continue; + } + else + { + break; + } + } + mediump float _252 = 6.283185482025146484375 / float(u_samplesEdge); + float param_4 = _252 * 0.5; + _t11 = _f0(param_4) * vec2(1.0, 0.0); + float param_5 = _252; + _t12 = _f0(param_5); + for (mediump int _t29 = 0; _t29 < u_samplesEdge; _t29++) + { + float _279 = abs(_t11.y * 8.659999847412109375); + float _283 = abs(_t11.x * 8.659999847412109375); + float _285 = 2.2999999523162841796875 * sqrt(_283); + mediump vec4 _336 = texture2D(_p0, (_93 + (_109 * ((_t11 * _p2) * vec2(u_scale.x, u_scale.y * (mix(((_279 - _285) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _283))) + 3.0, (_279 + _285) - 3.0, step(0.0, _t11.y)) / (_279 + 1.0000000133514319600180897396058e-10)))))) * _89); + vec4 param_6 = _336; + vec4 _340 = _f1(param_6); + _t14 = max(_t14, _336); + _t15 += (_336 * _340); + _t16 += _340; + _t11 = _t12 * _t11; + } + vec4 _363 = clamp(_t15 / _t16, vec4(0.0), vec4(1.0)); + return vec4(mix(_363, _t14, clamp(_363 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f2(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/dd624ee029b8b586e32df514c8b60dca.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.frag new file mode 100644 index 0000000000000000000000000000000000000000..d57c42fab585de009e4f13f31a681d064beeba2d --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.frag @@ -0,0 +1,42 @@ +precision highp float; +precision highp int; + +uniform mediump int u_samples; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, vec2 _p2) +{ + float param = 0.0; + float param_1 = 4.0; + float _48 = _f0(param, param_1); + float _t1 = _48; + vec2 _t2 = vec2(1.0) / _p2; + vec4 _t3 = texture2D(_p0, _p1) * _48; + mediump float _66 = float(u_samples); + for (mediump int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _66) * 15.0; + float param_3 = 4.0; + float _91 = _f0(param_2, param_3); + vec2 _100 = vec2(0.0, _t2.y * float(_t5)); + _t3 = (_t3 + (texture2D(_p0, _p1 + _100) * _91)) + (texture2D(_p0, _p1 - _100) * _91); + _t1 += (_91 + _91); + } + return _t3 / vec4(_t1); +} + +void main() +{ + vec2 param = v_uv; + vec2 param_1 = u_screenSize; + gl_FragData[0] = _f1(u_inputTex, param, param_1); +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/e59110e6ddde61cf6155d558258ba1be.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.frag new file mode 100644 index 0000000000000000000000000000000000000000..a73cc69acc4b1bc491659867bb69e9fb61efd07e --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.frag @@ -0,0 +1,93 @@ +precision highp float; +precision highp int; + +uniform float u_regionIns; +uniform float u_angle0; +uniform mediump int u_lineNum; +uniform mediump int u_samplesCore; +uniform float u_shapeIns; +uniform float u_scale; +uniform mediump int u_samplesEdge; +uniform float u_lightIns; +uniform float u_radius; +uniform mediump sampler2D u_inputTex; +uniform vec2 u_screenSize; + +varying vec2 v_uv; + +vec4 _f0(vec4 _p0) +{ + vec4 _29 = _p0 * _p0; + vec4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + vec4(0.4000000059604644775390625); +} + +vec4 _f1(mediump sampler2D _p0, vec2 _p1, float _p2, vec2 _p3) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + vec2 _66 = vec2(1.0) / _p3; + vec2 _70 = _p1 * _p3; + vec4 _t10 = vec4(0.0); + vec4 _t11 = vec4(0.0); + vec4 _t12 = vec4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + vec2 _t15 = vec2(1.0, 0.0); + mat2 _t16 = mat2(vec2(-0.737368881702423095703125, -0.675490319728851318359375), vec2(0.675490319728851318359375, -0.737368881702423095703125)); + mediump float _101 = 6.283185482025146484375 / float(u_lineNum); + float _105 = _101 * 0.5; + float _108 = sin(_105); + for (mediump int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _129 = _t13; + float _135 = abs(mod(_129, _101) - _105); + float _149 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _135)) + sin(_135)); + mediump vec4 _171 = texture2D(_p0, (_70 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _149))) * _66); + vec4 param = _171; + vec4 _181 = _f0(param) * ((u_regionIns * _149) * _149); + _t10 = max(_t10, _171 * _58); + _t11 += (_171 * _181); + _t13 += _t14; + _t12 += _181; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + mediump float _208 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _208; + float _210 = cos(_208); + float _212 = sin(_208); + _t15 = vec2(_p2, 0.0); + _t16 = mat2(vec2(_210, -_212), vec2(_212, _210)); + for (mediump int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + float _239 = _t13; + float _245 = abs(mod(_239, _101) - _105); + float _258 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _245)) + sin(_245)); + mediump vec4 _272 = texture2D(_p0, (_70 + ((_t15 * u_scale) * _258)) * _66); + vec4 param_1 = _272; + vec4 _280 = _f0(param_1) * (_258 * _258); + _t10 = max(_t10, _272); + _t11 += (_272 * _280); + _t13 += _t14; + _t12 += _280; + _t15 = _t16 * _t15; + } + vec4 _306 = clamp(_t11 / _t12, vec4(0.0), vec4(1.0)); + return vec4(mix(_306, _t10, clamp(_306 * u_lightIns, vec4(0.0), vec4(1.0)))); +} + +void main() +{ + if (u_radius < 0.100000001490116119384765625) + { + gl_FragData[0] = texture2D(u_inputTex, v_uv); + } + else + { + vec2 param = v_uv; + float param_1 = u_radius; + vec2 param_2 = u_screenSize; + gl_FragData[0] = _f1(u_inputTex, param, param_1, param_2); + } +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.vert new file mode 100644 index 0000000000000000000000000000000000000000..5d5ef431f3f2e4569c301c5bf87a0ad46053bf8b --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderGLES/f675c29a063820921bbbf9df56a3b146.vert @@ -0,0 +1,11 @@ + +attribute vec4 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = a_position; + v_uv = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.frag new file mode 100644 index 0000000000000000000000000000000000000000..7251087392c68129b65a3106ea6066dff35d7415 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/103fe4fa2cd41b88b7928e3c1e99a21c.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag new file mode 100644 index 0000000000000000000000000000000000000000..290a8760aac3d8920edd9afc55603c520f7c409e --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.frag @@ -0,0 +1,104 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_samples; + float2 u_screenSize; + float u_intensity; + float u_darkIns; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float2& _p2, constant int& u_samples) +{ + float param = 0.0; + float param_1 = 4.0; + float _66 = _f0(param, param_1); + float _t1 = _66; + float2 _t2 = float2(1.0) / _p2; + float4 _t3 = _p0.sample(_p0Smplr, _p1) * _66; + float _83 = float(u_samples); + for (int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _83) * 15.0; + float param_3 = 4.0; + float _108 = _f0(param_2, param_3); + float2 _117 = float2(_t2.x * float(_t5), 0.0); + _t3 = (_t3 + (_p0.sample(_p0Smplr, (_p1 + _117)) * _108)) + (_p0.sample(_p0Smplr, (_p1 - _117)) * _108); + _t1 += (_108 + _108); + } + return _t3 / float4(_t1); +} + +static inline __attribute__((always_inline)) +float3 _f2(thread const float4& _p0) +{ + return mix(float3(0.0), _p0.xyz / float3(_p0.w + 9.9999997473787516355514526367188e-05), float3(step(9.9999997473787516355514526367188e-05, _p0.w))); +} + +static inline __attribute__((always_inline)) +float3 _f3(texture2d _p0, sampler _p0Smplr, thread float3& _p1) +{ + _p1 *= 63.0; + float2 _178 = float2(floor(_p1.z), ceil(_p1.z)); + float2 _t10 = _178; + float2 _183 = floor(_178 * 0.125); + float4 _216 = (float4(_178 - (_183 * 8.0), _183).xzyw * 0.125) + float4(((_p1.xy + float2(0.5)) * 0.001953125).xyxy); + return mix(_p0.sample(_p0Smplr, _216.xy).xyz, _p0.sample(_p0Smplr, _216.zw).xyz, float3(_p1.z - _t10.x)); +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float4& _p0, texture2d _p1, sampler _p1Smplr, thread const float& _p2) +{ + float4 param = _p0; + float3 _242 = _f2(param); + float3 _t17 = _242; + float3 param_1 = _242; + float3 _246 = _f3(_p1, _p1Smplr, param_1); + float3 _247 = _t17; + float3 _251 = mix(_247, _246, float3(_p2)); + _t17 = _251; + return float4(_251, 1.0) * _p0.w; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], texture2d u_noiseTex [[texture(1)]], texture2d u_filterTex [[texture(2)]], sampler u_inputTexSmplr [[sampler(0)]], sampler u_noiseTexSmplr [[sampler(1)]], sampler u_filterTexSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float2 param = in.v_uv; + float2 param_1 = buffer.u_screenSize; + float4 _272 = _f1(u_inputTex, u_inputTexSmplr, param, param_1, buffer.u_samples); + float4 _t19 = _272; + float4 param_2 = _272; + float param_3 = (0.5 * buffer.u_intensity) * buffer.u_darkIns; + float4 _313 = _f4(param_2, u_filterTex, u_filterTexSmplr, param_3); + _t19 = _313; + float3 _315 = _313.xyz; + float3 _330 = mix(_315, _315 * ((u_noiseTex.sample(u_noiseTexSmplr, fract(((in.v_uv * buffer.u_screenSize) / float2(fast::min(buffer.u_screenSize.x, buffer.u_screenSize.y))) * 2.0)).x * 1.0) + 0.0), float3(((dot(_272.xyz, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)) * 0.100000001490116119384765625) * buffer.u_intensity) * buffer.u_darkIns)); + _t19.x = _330.x; + _t19.y = _330.y; + _t19.z = _330.z; + out.o_fragColor = _t19; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/19a1f32b0e9dc0a9b2bb21c7d904b4d2.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.frag new file mode 100644 index 0000000000000000000000000000000000000000..f1990f304b2527f37f4fe5e15b8d2e5edbd70ba4 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.frag @@ -0,0 +1,121 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float u_regionIns; + float u_angle0; + int u_lineNum; + int u_samplesCore; + float u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return float2x2(float2(_36, -_33), float2(_33, _36)); +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float4& _p0) +{ + float4 _52 = _p0 * _p0; + float4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant float& u_angle0, constant int& u_lineNum, constant int& u_samplesCore, constant float& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _84 = float2(1.0) / _p3; + float2 _88 = _p1 * _p3; + float4 _t10 = float4(0.0); + float4 _t11 = float4(0.0); + float4 _t12 = float4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + float2 _t15 = float2(1.0, 0.0); + float param = 2.3999631404876708984375; + float2x2 _t16 = _f0(param); + float _111 = 6.283185482025146484375 / float(u_lineNum); + float _115 = _111 * 0.5; + float _118 = cos(_115); + for (int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _139 = _t13; + float _148 = _118 / cos(mod(_139, _111) - _115); + float4 _170 = _p0.sample(_p0Smplr, ((_88 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _148))) * _84)); + float4 param_1 = _170; + float4 _180 = _f1(param_1) * ((u_regionIns * _148) * _148); + _t10 = fast::max(_t10, _170 * _80); + _t11 += (_170 * _180); + _t13 += _t14; + _t12 += _180; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + float _207 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _207; + _t15 = float2(_p2, 0.0); + float param_2 = _207; + _t16 = _f0(param_2); + for (int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + float4 _252 = _p0.sample(_p0Smplr, ((_88 + ((_t15 * u_scale) * (_118 / cos(mod(_t13, _111) - _115)))) * _84)); + float4 param_3 = _252; + float4 _256 = _f1(param_3); + _t10 = fast::max(_t10, _252); + _t11 += (_252 * _256); + _t13 += _t14; + _t12 += _256; + _t15 = _t16 * _t15; + } + float4 _282 = fast::clamp(_t11 / _t12, float4(0.0), float4(1.0)); + return float4(mix(_282, _t10, fast::clamp(_282 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f2(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_angle0, buffer.u_lineNum, buffer.u_samplesCore, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/62098be95c32361124a4da28939149f9.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..ecfe3f96fd7aa905b719a695a5f7cdd5589f0ab5 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.frag @@ -0,0 +1,93 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_regionIns; + int u_samplesCore; + float2 u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f0(thread const float4& _p0) +{ + float4 _29 = _p0 * _p0; + float4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant int& u_samplesCore, constant float2& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _66 = float2(1.0) / _p3; + float2 _70 = _p1 * _p3; + float2 _t10 = float2(1.0, 0.0); + float2x2 _t11 = float2x2(float2(-0.737368881702423095703125, -0.675490319728851318359375), float2(0.675490319728851318359375, -0.737368881702423095703125)); + float4 _t12 = float4(0.0); + float4 _t13 = float4(0.0); + float4 _t14 = float4(0.0); + for (int _t15 = 0; _t15 <= u_samplesCore; _t15++) + { + float4 _130 = _p0.sample(_p0Smplr, ((_70 + ((_t10 * u_scale) * (sqrt(float(_t15) / float(u_samplesCore)) * _p2))) * _66)); + float4 param = _130; + float4 _136 = _f0(param) * u_regionIns; + _t12 = fast::max(_t12, _130 * _58); + _t13 += (_130 * _136); + _t14 += _136; + _t10 = _t11 * _t10; + } + float _161 = 6.283185482025146484375 / float(u_samplesEdge); + float _163 = cos(_161); + float _165 = sin(_161); + _t10 = float2(_p2, 0.0); + _t11 = float2x2(float2(_163, -_165), float2(_165, _163)); + for (int _t22 = 0; _t22 < u_samplesEdge; _t22++) + { + float4 _196 = _p0.sample(_p0Smplr, ((_70 + (_t10 * u_scale)) * _66)); + float4 param_1 = _196; + float4 _200 = _f0(param_1); + _t12 = fast::max(_t12, _196); + _t13 += (_196 * _200); + _t14 += _200; + _t10 = _t11 * _t10; + } + float4 _223 = fast::clamp(_t13 / _t14, float4(0.0), float4(1.0)); + return float4(mix(_223, _t12, fast::clamp(_223 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f1(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_samplesCore, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/868e1e61a1297466576af58f026175ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.frag new file mode 100644 index 0000000000000000000000000000000000000000..b8ee25330b7889fcad393af1609f5ea4f0a8aa86 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.frag @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d u_maskTex [[texture(0)]], sampler u_maskTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float _t0 = fast::min(u_maskTex.sample(u_maskTexSmplr, in.v_uv).x, 99.0); + for (int _t2 = -1; _t2 <= 1; _t2++) + { + for (int _t3 = -1; _t3 <= 1; _t3++) + { + _t0 = fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + (float2(float(_t2), float(_t3)) * float2(0.014999999664723873138427734375)))).x, _t0); + } + } + float _79 = _t0; + float _111 = fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(0.0, -0.02999999932944774627685546875))).x, fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(0.0, 0.02999999932944774627685546875))).x, fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(0.02999999932944774627685546875, 0.0))).x, fast::min(u_maskTex.sample(u_maskTexSmplr, (in.v_uv + float2(-0.02999999932944774627685546875, 0.0))).x, _79)))); + _t0 = _111; + out.o_fragColor = float4(_111, _111, _111, 1.0); + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.vert new file mode 100644 index 0000000000000000000000000000000000000000..5cc14a84ffd84f48e3d4f8eea81d69228b466b55 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/c9c77ccd73acc8e37602b524fa0fc7d8.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float3 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = float4(in.a_position, 1.0); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.frag new file mode 100644 index 0000000000000000000000000000000000000000..4c74acdf4aa5346d5c4131e9504df05e5169dbaa --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.frag @@ -0,0 +1,165 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct buffer_t +{ + float u_regionIns; + int u_samples; + float u_angle0; + float2 u_scale; + int u_pointCount; + spvUnsafeArray u_contours; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _40 = sin(_p0); + float _43 = cos(_p0); + return float2x2(float2(_43, -_40), float2(_40, _43)); +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1, thread const float& _p2) +{ + return (_p2 - _p0) / (_p1 - _p0); +} + +static inline __attribute__((always_inline)) +float4 _f2(thread const float4& _p0) +{ + float4 _68 = _p0 * _p0; + float4 _72 = _68 * _68; + return (((_72 * _72) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f3(texture2d _p0, sampler _p0Smplr, texture2d _p1, sampler _p1Smplr, thread const float2& _p2, thread const float& _p3, thread const float2& _p4, constant float& u_regionIns, constant int& u_samples, constant float& u_angle0, constant float2& u_scale, constant int& u_pointCount, constant spvUnsafeArray& u_contours, constant float& u_lightIns) +{ + float _96 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _100 = float2(1.0) / _p4; + float2 _104 = _p2 * _p4; + float _110 = float(u_samples); + float _114 = _p3 / _110; + float4 _t12 = float4(0.0); + float4 _t13 = float4(0.0); + float4 _t14 = float4(0.0); + float param = u_angle0; + float2x2 _124 = _f0(param); + int _128 = -u_samples; + for (int _t16 = _128; _t16 <= u_samples; _t16++) + { + float _140 = float(_t16); + float _143 = -_110; + float param_1 = _143; + float param_2 = _110; + float param_3 = _140; + float _149 = _f1(param_1, param_2, param_3); + for (int _t19 = _128; _t19 <= u_samples; _t19++) + { + float _163 = float(_t19); + float param_4 = _143; + float param_5 = _110; + float param_6 = _163; + if (0.5 > _p1.sample(_p1Smplr, float2(_149, _f1(param_4, param_5, param_6))).x) + { + continue; + } + float4 _208 = _p0.sample(_p0Smplr, ((_104 + (_124 * ((float2(_140, _163) * u_scale) * _114))) * _100)); + float4 param_7 = _208; + float4 _214 = _f2(param_7) * u_regionIns; + _t12 = fast::max(_t12, _208 * _96); + _t13 += (_208 * _214); + _t14 += _214; + } + } + for (int _t26 = 0; _t26 < 500; _t26++) + { + if (_t26 >= u_pointCount) + { + break; + } + float4 _281 = _p0.sample(_p0Smplr, ((_104 + (_124 * ((((u_contours[_t26] * 2.0) - float2(1.0)) * u_scale) * _p3))) * _100)); + float4 param_8 = _281; + float4 _285 = _f2(param_8); + _t12 = fast::max(_t12, _281); + _t13 += (_281 * _285); + _t14 += _285; + } + float4 _305 = fast::clamp(_t13 / _t14, float4(0.0), float4(1.0)); + return float4(mix(_305, _t12, fast::clamp(_305 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], texture2d u_maskTex [[texture(1)]], sampler u_inputTexSmplr [[sampler(0)]], sampler u_maskTexSmplr [[sampler(1)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f3(u_inputTex, u_inputTexSmplr, u_maskTex, u_maskTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_samples, buffer.u_angle0, buffer.u_scale, buffer.u_pointCount, buffer.u_contours, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/d0e14dc2bd079d4169a342ccb3aa77ef.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.frag new file mode 100644 index 0000000000000000000000000000000000000000..b0360d5d63c66e31836118d4e12d3d7f8246119c --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.frag @@ -0,0 +1,126 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float u_regionIns; + float u_angle0; + int u_samplesCore; + float2 u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2x2 _f0(thread const float& _p0) +{ + float _33 = sin(_p0); + float _36 = cos(_p0); + return float2x2(float2(_36, -_33), float2(_33, _36)); +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float4& _p0) +{ + float4 _52 = _p0 * _p0; + float4 _56 = _52 * _52; + return (((_56 * _56) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant float& u_angle0, constant int& u_samplesCore, constant float2& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _80 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _89 = float2(1.0) / _p3; + float2 _93 = _p1 * _p3; + float param = 0.00999999977648258209228515625; + float2 _t11 = _f0(param) * float2(1.0, 0.0); + float param_1 = 2.3999631404876708984375; + float2x2 _t12 = _f0(param_1); + float param_2 = u_angle0; + float2x2 _109 = _f0(param_2); + float4 _t14 = float4(0.0); + float4 _t15 = float4(0.0); + float4 _t16 = float4(0.0); + int _t17 = 0; + for (;;) + { + float _128 = float(u_samplesCore); + float _130 = _128 * 0.0500000007450580596923828125; + int _131 = int(_130); + int _132 = u_samplesCore - _131; + if (_t17 <= _132) + { + float _154 = abs(_t11.y * 8.659999847412109375); + float _159 = abs(_t11.x * 8.659999847412109375); + float _161 = 2.2999999523162841796875 * sqrt(_159); + float4 _219 = _p0.sample(_p0Smplr, ((_93 + (_109 * ((_t11 * (sqrt(float(_t17) / _128) * _p2)) * float2(u_scale.x, u_scale.y * (mix(((_154 - _161) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _159))) + 3.0, (_154 + _161) - 3.0, step(0.0, _t11.y)) / (_154 + 1.0000000133514319600180897396058e-10)))))) * _89)); + float4 param_3 = _219; + float4 _227 = _f1(param_3) * (u_regionIns * 2.0); + _t14 = fast::max(_t14, _219 * _80); + _t15 += (_219 * _227); + _t16 += _227; + _t11 = _t12 * _t11; + _t17++; + continue; + } + else + { + break; + } + } + float _252 = 6.283185482025146484375 / float(u_samplesEdge); + float param_4 = _252 * 0.5; + _t11 = _f0(param_4) * float2(1.0, 0.0); + float param_5 = _252; + _t12 = _f0(param_5); + for (int _t29 = 0; _t29 < u_samplesEdge; _t29++) + { + float _279 = abs(_t11.y * 8.659999847412109375); + float _283 = abs(_t11.x * 8.659999847412109375); + float _285 = 2.2999999523162841796875 * sqrt(_283); + float4 _336 = _p0.sample(_p0Smplr, ((_93 + (_109 * ((_t11 * _p2) * float2(u_scale.x, u_scale.y * (mix(((_279 - _285) - (1.2999999523162841796875 * smoothstep(1.2999999523162841796875, 0.0, _283))) + 3.0, (_279 + _285) - 3.0, step(0.0, _t11.y)) / (_279 + 1.0000000133514319600180897396058e-10)))))) * _89)); + float4 param_6 = _336; + float4 _340 = _f1(param_6); + _t14 = fast::max(_t14, _336); + _t15 += (_336 * _340); + _t16 += _340; + _t11 = _t12 * _t11; + } + float4 _363 = fast::clamp(_t15 / _t16, float4(0.0), float4(1.0)); + return float4(mix(_363, _t14, fast::clamp(_363 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f2(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_angle0, buffer.u_samplesCore, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/dd624ee029b8b586e32df514c8b60dca.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.frag new file mode 100644 index 0000000000000000000000000000000000000000..d8bdd8b92d28d76ff40fcf75e84f7c65ba6f4e43 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.frag @@ -0,0 +1,60 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int u_samples; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + return (0.3989399969577789306640625 * exp((((-0.5) * _p0) * _p0) / (_p1 * _p1))) / _p1; +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float2& _p2, constant int& u_samples) +{ + float param = 0.0; + float param_1 = 4.0; + float _48 = _f0(param, param_1); + float _t1 = _48; + float2 _t2 = float2(1.0) / _p2; + float4 _t3 = _p0.sample(_p0Smplr, _p1) * _48; + float _66 = float(u_samples); + for (int _t5 = 1; _t5 <= u_samples; _t5++) + { + float param_2 = (float(_t5) / _66) * 15.0; + float param_3 = 4.0; + float _91 = _f0(param_2, param_3); + float2 _100 = float2(0.0, _t2.y * float(_t5)); + _t3 = (_t3 + (_p0.sample(_p0Smplr, (_p1 + _100)) * _91)) + (_p0.sample(_p0Smplr, (_p1 - _100)) * _91); + _t1 += (_91 + _91); + } + return _t3 / float4(_t1); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float2 param = in.v_uv; + float2 param_1 = buffer.u_screenSize; + out.o_fragColor = _f1(u_inputTex, u_inputTexSmplr, param, param_1, buffer.u_samples); + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/e59110e6ddde61cf6155d558258ba1be.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.frag new file mode 100644 index 0000000000000000000000000000000000000000..a83bc011d7993d7bd0504aac94fe389c7a1bc1b5 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.frag @@ -0,0 +1,118 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + float u_regionIns; + float u_angle0; + int u_lineNum; + int u_samplesCore; + float u_shapeIns; + float u_scale; + int u_samplesEdge; + float u_lightIns; + float u_radius; + float2 u_screenSize; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f0(thread const float4& _p0) +{ + float4 _29 = _p0 * _p0; + float4 _33 = _29 * _29; + return (((_33 * _33) * _p0) * 539.45001220703125) + float4(0.4000000059604644775390625); +} + +static inline __attribute__((always_inline)) +float4 _f1(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, thread const float& _p2, thread const float2& _p3, constant float& u_regionIns, constant float& u_angle0, constant int& u_lineNum, constant int& u_samplesCore, constant float& u_shapeIns, constant float& u_scale, constant int& u_samplesEdge, constant float& u_lightIns) +{ + float _58 = mix(0.699999988079071044921875, 1.0, u_regionIns); + float2 _66 = float2(1.0) / _p3; + float2 _70 = _p1 * _p3; + float4 _t10 = float4(0.0); + float4 _t11 = float4(0.0); + float4 _t12 = float4(0.0); + float _t13 = u_angle0; + float _t14 = 2.3999631404876708984375; + float2 _t15 = float2(1.0, 0.0); + float2x2 _t16 = float2x2(float2(-0.737368881702423095703125, -0.675490319728851318359375), float2(0.675490319728851318359375, -0.737368881702423095703125)); + float _101 = 6.283185482025146484375 / float(u_lineNum); + float _105 = _101 * 0.5; + float _108 = sin(_105); + for (int _t20 = 0; _t20 <= u_samplesCore; _t20++) + { + float _129 = _t13; + float _135 = abs(mod(_129, _101) - _105); + float _149 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _135)) + sin(_135)); + float4 _171 = _p0.sample(_p0Smplr, ((_70 + ((_t15 * u_scale) * ((sqrt(float(_t20) / float(u_samplesCore)) * _p2) * _149))) * _66)); + float4 param = _171; + float4 _181 = _f0(param) * ((u_regionIns * _149) * _149); + _t10 = fast::max(_t10, _171 * _58); + _t11 += (_171 * _181); + _t13 += _t14; + _t12 += _181; + _t15 = _t16 * _t15; + } + _t13 = u_angle0; + float _208 = 6.283185482025146484375 / float(u_samplesEdge); + _t14 = _208; + float _210 = cos(_208); + float _212 = sin(_208); + _t15 = float2(_p2, 0.0); + _t16 = float2x2(float2(_210, -_212), float2(_212, _210)); + for (int _t27 = 0; _t27 < u_samplesEdge; _t27++) + { + float _239 = _t13; + float _245 = abs(mod(_239, _101) - _105); + float _258 = (u_shapeIns * _108) / ((u_shapeIns * sin(_105 - _245)) + sin(_245)); + float4 _272 = _p0.sample(_p0Smplr, ((_70 + ((_t15 * u_scale) * _258)) * _66)); + float4 param_1 = _272; + float4 _280 = _f0(param_1) * (_258 * _258); + _t10 = fast::max(_t10, _272); + _t11 += (_272 * _280); + _t13 += _t14; + _t12 += _280; + _t15 = _t16 * _t15; + } + float4 _306 = fast::clamp(_t11 / _t12, float4(0.0), float4(1.0)); + return float4(mix(_306, _t10, fast::clamp(_306 * u_lightIns, float4(0.0), float4(1.0)))); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTex [[texture(0)]], sampler u_inputTexSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_radius < 0.100000001490116119384765625) + { + out.o_fragColor = u_inputTex.sample(u_inputTexSmplr, in.v_uv); + } + else + { + float2 param = in.v_uv; + float param_1 = buffer.u_radius; + float2 param_2 = buffer.u_screenSize; + out.o_fragColor = _f1(u_inputTex, u_inputTexSmplr, param, param_1, param_2, buffer.u_regionIns, buffer.u_angle0, buffer.u_lineNum, buffer.u_samplesCore, buffer.u_shapeIns, buffer.u_scale, buffer.u_samplesEdge, buffer.u_lightIns); + } + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.vert new file mode 100644 index 0000000000000000000000000000000000000000..3cd70b5a4ee997d900adf3b543e4de0937ec2b8f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiBokehBlur/xshader/shaderLib/shaderMetal/f675c29a063820921bbbf9df56a3b146.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = in.a_position; + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..2546a0b4a866acc8a955166686a5ff42a5610048 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,649 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiAnimSeqLoadAndCrop_533-effect0', 'seqTex_1_1', 1}, + {'LumiAnimSeqLoadAndCrop_531-effect0', 'seqTex_1_1', 0}, + {'LumiLayer_49-blend', 'InputTex', 1}, + {'LumiLayer_49-blend', 'baseTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiAnimSeqLoadAndCrop_533-effect0'] = { + ['nodeDuration'] = {{0.83333333333333, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.83333333333333, 2}, }, + ['seqTex_1_1'] = {{1.03333333333333, 5}, }, + }, + }, + ['LumiBokehBlur_533-effect1'] = { + ['nodeDuration'] = {{0.83333333333333, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.83333333333333, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_531-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 5}, }, + }, + }, + ['LumiBokehBlur_531-effect1'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_49-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{1.03333333333333, 5}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, + ['LumiLayer_531-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, + ['LumiLayer_533-trs-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{0.83333333333333, 2}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_535-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiBCCGlowOBS_535-effect1'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + }, + }, + ['LumiLayer_535-blend'] = { + ['nodeDuration'] = {{0, 5}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 5}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiAnimSeqLoadAndCrop_533-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 2, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = false, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiBokehBlur_533-effect1'] = { + ['bokehMode'] = 0, + ['scale'] = 30, + ['scaleX'] = 1, + ['scaleY'] = 1, + ['regionIns'] = 0.5, + ['lightIns'] = 4, + ['darkIns'] = 2, + ['quality'] = 0.69999998807907, + ['angle'] = 0, + ['lineNum'] = 5, + ['shapeIns'] = 0.6, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiAnimSeqLoadAndCrop_531-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 2, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = false, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = false, + ['animSeqType_9_16'] = 2, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = false, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = false, + ['animSeqType_16_9'] = 2, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = false, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiBokehBlur_531-effect1'] = { + ['bokehMode'] = 0, + ['scale'] = 30, + ['scaleX'] = 1, + ['scaleY'] = 1, + ['regionIns'] = 0.5, + ['lightIns'] = 4, + ['darkIns'] = 2, + ['quality'] = 0.69999998807907, + ['angle'] = 0, + ['lineNum'] = 5, + ['shapeIns'] = 0.6, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_49-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiLayer_531-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Solid', + ['blendMode'] = 0, + }, + ['LumiLayer_533-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 50.000000000225, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_535-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiBCCGlowOBS_535-effect1'] = { + ['show'] = 2, + ['glowChannels'] = 0, + ['glowThreshold'] = 0.7, + ['glowRadius'] = 50, + ['glowAspectRatio'] = 0, + ['glowIntensity'] = 1, + ['combine'] = 1, + ['colorA'] = Amaz.Color(0, 0, 0, 1), + ['colorB'] = Amaz.Color(1, 1, 1, 1), + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_535-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Solid', + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiBokehBlur_533-effect1#scale#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.1, 1.5, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiBokehBlur_531-effect1#scale#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0.5, 1, }, + {{0, }, {30, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_533-trs-blend#opacity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.833333, 1.166667, }, + {{0, }, {100, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_535-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..7a07ee24e9b82500e89114ce8cb3a85474915e38 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,554 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo == 1 then + endTime = self.videoTime + else + curTime = 0 + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681200609197821202/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681200609197821202/config.json b/scripts/7681200609197821202/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7e059f6e5fbd0d978657cee0ab65c39eedd0c090 --- /dev/null +++ b/scripts/7681200609197821202/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.5", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903120219688", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681200609197821202/extra.json b/scripts/7681200609197821202/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681200609197821202/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/content.json b/scripts/7681214409993178375/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/JSSys.js b/scripts/7681214409993178375/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +1 @@ +const{ShaderPass}=require("./ShaderPass.js");const getCurrentScene=require("./three-amg-wrapper.js").getCurrentScene;const RenderPass=require("./RenderPass.js").RenderPass;const Texture=require("./wrapper/Texture").Texture;const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class EffectComposer{constructor(renderer){this.renderer=renderer;this.passes=[];this.scene=getCurrentScene();this.rt_0=this.scene._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this.rt_prev_Texture=null;this.rt_next_Texture=null;this.sourceEntity=this.scene._amgScene.findEntityBy("PerspectiveCamera_w");this.sourceCamera=this.sourceEntity?this.sourceEntity.getComponent("Camera"):null;this.outputEntity=this.scene._amgScene.findEntityBy("Camera")||this.sourceEntity;this.outputCamera=this.outputEntity?this.outputEntity.getComponent("Camera"):null;this._outputIsPerspective=!!(this.outputEntity&&this.outputEntity.name==="PerspectiveCamera_w");this._initialInputTexture=this.rt_0;this._currentInputTexture=this._initialInputTexture;this._ppPassCount=0;this.finalPlaceHolder=this.scene._amgScene.findEntityBy("PlaceHolder");this.outputRT=this.scene._amgScene.assetMgr.SyncLoad("rt/outputTex.rt");if(this.sourceEntity){this.sourceEntity.layer=0;if(this.sourceCamera){this.sourceCamera.renderOrder=0;this.sourceCamera.renderTexture=this.rt_0}}}_getStartOrder(){let startOrder=0;for(let i=0;i { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-6 * k) * Math.cos(12 * k); +}; + +// 欠阻尼弹簧(硬):更高频振荡、更慢收敛 +const springStiff = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(18 * k); +}; + +// 阻尼振荡:sin 基波收尾抖动 +const dampedOscillation = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(10 * k); +}; + +const Physics = Object.freeze({ + SpringSoft: springSoft, + SpringStiff: springStiff, + DampedOscillation: dampedOscillation, +}); + +// ─── §4 Motion 动作设计系 ────────────────────────────────────────────────── + +// 先回拉 10% 再冲向终点:蓄力动作 +const anticipate = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const pullback = 0.1; + if (k < 0.3) { + const p = k / 0.3; + return -pullback * p * (2 - p); // easeOutQuad 到 -pullback + } + const p = (k - 0.3) / 0.7; + return -pullback + (1 + pullback) * p * p * (3 - 2 * p); // smoothstep 到 1 +}; + +// 冲到 peak 再回到 1 的工厂 +const overshootFactory = (peak) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return peak * p * (2 - p); // easeOutQuad 到 peak + } + const p = (k - 0.6) / 0.4; + return peak + (1 - peak) * (1 - Math.pow(1 - p, 3)); // easeOutCubic 到 1 +}; + +const overshoot110 = overshootFactory(1.10); +const overshoot125 = overshootFactory(1.25); + +// 快速到位(前 60% 冲到 1.05),后 40% 回到 1:磁吸、卡扣 +const snapBack = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return 1.05 * (1 - Math.pow(1 - p, 3)); + } + const p = (k - 0.6) / 0.4; + return 1.05 - 0.05 * p * p * (3 - 2 * p); +}; + +// 摆锤式:一次轻微过冲后收敛 +const swing = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.cos(1.5 * Math.PI * k) * Math.exp(-2.5 * k); +}; + +const Motion = Object.freeze({ + Anticipate: anticipate, + Overshoot110: overshoot110, + Overshoot125: overshoot125, + SnapBack: snapBack, + Swing: swing, +}); + +// ─── §5 Step 步进系 ──────────────────────────────────────────────────────── + +/** + * CSS steps() 等价工厂。 + * @param {number} n 段数 + * @param {'start' | 'end'} jumpTerm 跳变在每段的起始还是结束(默认 'end') + */ +const makeStep = (n, jumpTerm = 'end') => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (jumpTerm === 'start') return Math.ceil(k * n) / n; + return Math.floor(k * n) / n; +}; + +const Step = Object.freeze({ + Steps4End: makeStep(4, 'end'), + Steps8End: makeStep(8, 'end'), + Steps12End: makeStep(12, 'end'), +}); + +// ─── §6 Bezier 规范贝塞尔 ────────────────────────────────────────────────── + +/** + * 给定两个控制点 (x1,y1) 与 (x2,y2),P0=(0,0) P3=(1,1)。 + * 返回函数 f(t) -> y,其中 t 是输入时间(需先用牛顿法从 x 反解 s)。 + */ +function buildCubicBezier(x1, y1, x2, y2) { + const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx; + const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by; + const sampleX = (s) => ((ax * s + bx) * s + cx) * s; + const sampleY = (s) => ((ay * s + by) * s + cy) * s; + const sampleDX = (s) => (3 * ax * s + 2 * bx) * s + cx; + + const solveS = (x) => { + let s = x; + for (let i = 0; i < 8; i++) { + const cur = sampleX(s) - x; + if (Math.abs(cur) < 1e-6) return s; + const d = sampleDX(s); + if (Math.abs(d) < 1e-6) break; + s -= cur / d; + if (s < 0) s = 0; + if (s > 1) s = 1; + } + // 兜底二分 + let lo = 0, hi = 1; + for (let i = 0; i < 32 && hi - lo > 1e-6; i++) { + const mid = (lo + hi) / 2; + if (sampleX(mid) < x) lo = mid; else hi = mid; + } + return (lo + hi) / 2; + }; + + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return sampleY(solveS(k)); + }; +} + +// 贝塞尔白名单:(x1, y1, x2, y2) +const BEZIER_PRESETS = Object.freeze({ + 'Material.Standard': [0.4, 0, 0.2, 1], + 'Material.Accelerate': [0.4, 0, 1, 1], + 'Material.Decelerate': [0, 0, 0.2, 1], + 'CSS.Ease': [0.25, 0.1, 0.25, 1], +}); + +// 工厂 memoization(避免同参数重复构造) +const _bezierCache = new Map(); +function _cachedBezier(x1, y1, x2, y2) { + const key = x1 + ',' + y1 + ',' + x2 + ',' + y2; + let fn = _bezierCache.get(key); + if (!fn) { + fn = buildCubicBezier(x1, y1, x2, y2); + _bezierCache.set(key, fn); + } + return fn; +} + +/** + * cubicBezier('Material.Standard') | cubicBezier(x1, y1, x2, y2) + * 直写参数受控域:x1/x2 ∈ [0,1],y1/y2 ∈ [-0.5, 1.5] + */ +function cubicBezier(a, b, c, d) { + if (typeof a === 'string') { + let preset = BEZIER_PRESETS[a]; + if (!preset) { + console.warn('[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:', a); + preset = BEZIER_PRESETS['Material.Standard']; + } + return _cachedBezier(preset[0], preset[1], preset[2], preset[3]); + } + // 数值入口:裁剪到允许域 + const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v)); + const x1 = clamp(a, 0, 1); + const y1 = clamp(b, -0.5, 1.5); + const x2 = clamp(c, 0, 1); + const y2 = clamp(d, -0.5, 1.5); + return _cachedBezier(x1, y1, x2, y2); +} + +// 命名贝塞尔实例已整组移除:Material/CSS 预设与原生 Sinusoidal/Quadratic/Cubic +// 数值上几乎等价,特殊场景请直接调用 cubicBezier('Material.Standard') 等工厂。 + +// ═══════════════════════════════════════════════════════════════════════════ +// 扩展分组(与已有 6 组并列,不污染既有命名空间) +// ═══════════════════════════════════════════════════════════════════════════ + +// ─── §7 业界库扩展(已并入 Physics / Step / Heart) ───────────────────────── +// 以下工厂原本聚合在 Lib.* 命名空间下,现已按语义归入相应主题: +// Spring (Framer Motion) → Progress.Physics.Spring +// Steps (GSAP) → Progress.Step.Steps6 +// HeartBeat → Wave.Heart.Beat +// 退役:Framer Motion 的 Anticipate / GSAP 的 Overshoot factory(由 Motion.* +// 覆盖);GSAP ExpoScale / Unity SmoothDamp(数值上与原生 Sinusoidal/Quadratic +// 等价,已整组移除)。 + +// Spring(Framer Motion 风格):参数化弹簧,离散积分 +const libSpring = ({ stiffness = 180, damping = 12, mass = 1 } = {}) => { + const DT = 1 / 240; + const T = 1.5; + let x = 0, v = 0; + const samples = []; + for (let t = 0; t <= T; t += DT) { + const force = -stiffness * (x - 1) - damping * v; + v += (force / mass) * DT; + x += v * DT; + samples.push({ t, x }); + } + let T_end = T; + for (let i = samples.length - 1; i >= 0; i--) { + if (Math.abs(samples[i].x - 1) > 0.01) { T_end = samples[i].t; break; } + } + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const t = k * T_end; + const idx = Math.min(samples.length - 1, Math.floor(t / DT)); + return samples[idx].x; + }; +}; + +// HeartBeat(简易版):两高斯峰的绝对值轨迹 +const libHeartBeat = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c) => Math.exp(-((t - c) ** 2) / (2 * 0.07 * 0.07)); + return peak * (bell(k, 0.2) + bell(k, 0.5)); +}; + +// Steps(GSAP SteppedEase 风格 factory):离散 N 段阶梯(默认 n=6) +const libSteps = (n = 6) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return Math.floor(k * n) / n; +}; + +// ─── §8 Attention 注意力 / 抖振 ──────────────────────────────────────────── + +// Ping:单次衰减脉冲(雷达 ping),sin(π·k) × exp(-decay·k) +const attentionPing = (peak = 0.35, decay = 2) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(Math.PI * k) * Math.exp(-decay * k); +}; + +// Wiggle:衰减正弦振荡(easing 值本身,非位置增量) +const attentionWiggle = (count = 4, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + return amplitude * env * Math.sin(k * Math.PI * 2 * count); +}; + +// Strum:多峰衰减(吉他拨弦) +const attentionStrum = (notes = 4, peak = 0.4) => { + const centers = []; + for (let i = 0; i < notes; i++) { + centers.push({ c: 0.15 + i * (0.7 / Math.max(1, notes - 1)), a: Math.pow(0.72, i) }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * 0.05 * 0.05)); + } + return peak * sum; + }; +}; + +const Attention = Object.freeze({ + Ping: attentionPing(), + Wiggle: attentionWiggle(), + Strum: attentionStrum(), +}); + +// ─── §9 Breath 呼吸 ──────────────────────────────────────────────────────── + +// Normal:慢节奏正弦呼吸 +const breathNormal = (cycles = 2, peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(k * Math.PI * 2 * cycles) * Math.sin(k * Math.PI); +}; + +// Deep:深呼吸——慢吸气 → hold → 慢呼气 +const breathDeep = (peak = 0.3, riseRatio = 0.35, holdRatio = 0.15) => { + const holdEnd = riseRatio + holdRatio; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + if (k < holdEnd) { + return peak; + } + const t = (k - holdEnd) / (1 - holdEnd); + return peak * Math.cos(t * Math.PI / 2); + }; +}; + +// Panting:急促浅呼吸——多次小幅起伏 + 正弦包络 +const breathPanting = (cycles = 6, peak = 0.08) => (k) => { + if (k <= 0 || k >= 1) return 0; + const envelope = Math.sin(k * Math.PI); + const wave = 0.5 + 0.5 * Math.sin(k * Math.PI * 2 * cycles - Math.PI / 2); + return peak * envelope * wave; +}; + +// Sigh:叹息——快速吸气后慢速释放 +const breathSigh = (peak = 0.25, riseRatio = 0.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + const t = (k - riseRatio) / (1 - riseRatio); + return peak * (1 - t) * (1 - t); +}; + +const Breath = Object.freeze({ + Normal: breathNormal(), + Deep: breathDeep(), + Panting: breathPanting(), + Sigh: breathSigh(), +}); + +// ─── §10 Heart 心跳 ──────────────────────────────────────────────────────── + +// Calm:单次舒缓心跳——单高斯峰 +const heartCalm = (peak = 0.25, center = 0.35, width = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.exp(-((k - center) ** 2) / (2 * width * width)); +}; + +// Excited:兴奋/紧张——密集快速心跳(N 连击) +const heartExcited = (beats = 4, peak = 0.3, width = 0.04) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < beats; i++) { + centers.push(0.15 + i * (span / Math.max(1, beats - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * width * width)); + } + return peak * sum; + }; +}; + +// LubDub:标准心跳「lub-dub」双音节 +const heartLubDub = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + // lub(S1):中心 0.25、宽 0.045、幅 1.0 + // dub(S2):中心 0.42、宽 0.03、幅 0.6 + return peak * (bell(k, 0.25, 0.045) + 0.6 * bell(k, 0.42, 0.03)); +}; + +const Heart = Object.freeze({ + Calm: heartCalm(), + Excited: heartExcited(), + LubDub: heartLubDub(), +}); + +// ─── §11 Math 物理 / 数学 ───────────────────────────────────────────────── + +// JumpArc:抛物线轨迹 4k(1-k) +const mathJumpArc = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 4 * k * (1 - k); +}; + +// Pendulum:物理摆——sin(πk) 包络的衰减余弦,端点归零(满足 Wave 契约 f(0)=f(1)=0) +const mathPendulum = (damping = 3, freq = 2.5) => (k) => { + if (k <= 0 || k >= 1) return 0; + return Math.sin(k * Math.PI) * Math.exp(-damping * k) * Math.cos(freq * Math.PI * k); +}; + +// Tremor:持续高频小幅抖动(不衰减),整体沿 Linear 进行 +const mathTremor = (amplitude = 0.04, freq = 22) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return k + amplitude * Math.sin(k * Math.PI * 2 * freq); +}; + +// Boomerang 包装器:把任意 easing 包装成 0→1→0(先去再回)。 +// 仅作为内部辅助使用,不暴露为公共曲线——常用变体已预实例化为 +// Pulse.Math.BoomerangSharp / BoomerangSoft(见 Pulse 命名空间)。 +const mathBoomerang = (fn) => (k) => { + if (k <= 0 || k >= 1) return 0; + return k < 0.5 ? fn(k * 2) : fn(2 - k * 2); +}; + +const MathExt = Object.freeze({ + JumpArc: mathJumpArc(), + Pendulum: mathPendulum(), + Tremor: mathTremor(), +}); + +// ─── §12 Explosion 爆炸 ──────────────────────────────────────────────────── + +// Impulse:指数脉冲响应 k·e^(1-k·sharpness)(减线性尾项使 k=1 归 0) +const explosionImpulse = (sharpness = 6) => { + const tail = sharpness * Math.exp(1 - sharpness); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const h = sharpness * k; + return h * Math.exp(1 - h) - tail * k; + }; +}; + +// Flash:瞬间拉满 + 指数衰减到 0 +const explosionFlash = (rise = 0.05, decay = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < rise) return k / rise; + return Math.exp(-decay * (k - rise)); +}; + +// Recoil:爆炸反冲——负向冲击 -1 + 阻尼振荡 +const explosionRecoil = (decay = 4, freq = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + return -Math.exp(-decay * k) * Math.cos(freq * Math.PI * k); +}; + +// Implosion:三段式——负向吸能 → 正向爆发 → 衰减归 0 +const explosionImplosion = (charge = 0.3, depth = 0.4, burstPeak = 1.2) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < charge) { + const t = k / charge; + return -depth * Math.sin(t * Math.PI / 2); + } + const t = (k - charge) / (1 - charge); + const h = sharp * t; + const wave = h * Math.exp(1 - h) - tail * t; + const settle = -depth * Math.pow(1 - t, 3); + return settle + burstPeak * wave; + }; +}; + +const Explosion = Object.freeze({ + Impulse: explosionImpulse(), + Flash: explosionFlash(), + Recoil: explosionRecoil(), + Implosion: explosionImplosion(), +}); + +// ─── §13 Cinema(已整组移除:Creep=k^3.5 与 Cubic.In/Quartic.In 数值等价) ─ + +// ─── §14 Nature 自然现象 ─────────────────────────────────────────────────── + +// Wave:海浪律动——多谐波叠加 + 整体正弦包络 +const natureWave = (cycles = 3, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const w = Math.sin(k * Math.PI * 2 * cycles) + + 0.5 * Math.sin(k * Math.PI * 2 * cycles * 1.5 + 1.2) + + 0.25 * Math.sin(k * Math.PI * 2 * cycles * 3 + 2.4); + return amplitude * env * w * 0.6; +}; + +// Flicker:火焰闪烁——伪随机采样 + 线性插值 + 正弦包络 +const natureFlicker = (rate = 15, intensity = 0.2, seed = 7) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= rate + 1; i++) samples.push(rand()); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * rate; + const idx = Math.floor(pos); + const t = pos - idx; + const a = samples[idx]; + const b = samples[idx + 1]; + const interp = a + (b - a) * t; + return intensity * env * (interp - 0.5) * 2; + }; +}; + +// Gust:风——N 次高斯阵风叠加 +const natureGust = (gusts = 3, peak = 0.25) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < gusts; i++) { + centers.push(0.15 + i * (span / Math.max(1, gusts - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * 0.08 * 0.08)); + } + return peak * sum / gusts * 1.8; + }; +}; + +const Nature = Object.freeze({ + Wave: natureWave(), + Flicker: natureFlicker(), + Gust: natureGust(), +}); + +// ─── §15 Impact 撞击 / 落地 ──────────────────────────────────────────────── + +// Rain:雨滴下落——重力加速段 + 撞击 + 小幅余震 +const impactRain = (impactAt = 0.7, rippleAmp = 0.08) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + return 1 + rippleAmp * Math.exp(-4 * t) * Math.sin(t * Math.PI * 6); +}; + +// Hammer:锤击——抬起蓄力(负值)→ 快速下击 → 微反弹 +const impactHammer = (liftDepth = 0.25) => { + const liftEnd = 0.35, strikeEnd = 0.6; + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < liftEnd) { + const t = k / liftEnd; + return -liftDepth * Math.sin(t * Math.PI); + } + if (k < strikeEnd) { + const t = (k - liftEnd) / (strikeEnd - liftEnd); + return t * t; + } + const t = (k - strikeEnd) / (1 - strikeEnd); + return 1 - 0.06 * Math.exp(-5 * t) * Math.sin(t * Math.PI * 4); + }; +}; + +// BounceDrop:下落 + 多次衰减反弹 +const impactBounceDrop = (bounces = 3, rebound = 0.25) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return t * t; + } + const t = (k - 0.4) / 0.6; + const env = Math.exp(-2.5 * t); + const wave = Math.abs(Math.sin(t * Math.PI * bounces)); + return 1 - env * wave * rebound; +}; + +// Slap:拍击——快速接触 + 短暂保持 + 快速撤回 +const impactSlap = (contactAt = 0.3, holdRatio = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < contactAt) { + const t = k / contactAt; + return t * t; + } + if (k < contactAt + holdRatio) return 1; + const t = (k - contactAt - holdRatio) / (1 - contactAt - holdRatio); + return (1 - t) * (1 - t); +}; + +// ArrowHit:箭中靶——匀速飞行 + 命中 + 插入后高频振颤衰减 +const impactArrowHit = (impactAt = 0.5) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * (0.7 + 0.3 * t); + } + const t = (k - impactAt) / (1 - impactAt); + const env = Math.exp(-5 * t); + const wave = Math.sin(t * Math.PI * 10); + return 1 + 0.1 * env * wave; +}; + +// Shatter:撞碎——下落 + 撞击 + 能量 impulse 爆发 + 回到 1 +const impactShatter = (impactAt = 0.55, burstAmp = 0.35) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + const h = sharp * t; + const impulseVal = h * Math.exp(1 - h) - tail * t; + return 1 + burstAmp * impulseVal; + }; +}; + +const Impact = Object.freeze({ + Rain: impactRain(), + Hammer: impactHammer(), + BounceDrop: impactBounceDrop(), + Slap: impactSlap(), + ArrowHit: impactArrowHit(), + Shatter: impactShatter(), +}); + +// ─── §16 Rhythm 节奏 / 冲击 ──────────────────────────────────────────────── + +// BassDrop:EDM 重拍——缓慢蓄力 → pause pre-drop → 瞬间掉到 1 → 持续并有微脉动 +const rhythmBassDrop = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return 0.4 * Math.pow(t, 2.5); + } + if (k < 0.48) { + const t = (k - 0.4) / 0.08; + return 0.4 - 0.2 * t; + } + if (k < 0.52) { + const t = (k - 0.48) / 0.04; + return 0.2 + 0.8 * t; + } + const t = (k - 0.52) / 0.48; + return 1 - 0.04 * Math.sin(t * Math.PI * 8) * (1 - t); +}; + +// PunchCombo:拳击三连击——jab-jab-cross,第三拳最重最宽 +const rhythmPunchCombo = (peak = 0.4) => { + const pattern = [ + { c: 0.15, w: 0.04, a: 0.75 }, + { c: 0.35, w: 0.04, a: 0.75 }, + { c: 0.7, w: 0.055, a: 1.0 }, + ]; + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of pattern) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return peak * sum; + }; +}; + +// Staccato:断奏——均匀节拍内 duty 占空比 sin 脉冲 +const rhythmStaccato = (beats = 4, duty = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const beatLen = 1 / beats; + const phase = (k / beatLen) - Math.floor(k / beatLen); + if (phase > duty) return 0; + const t = phase / duty; + return Math.sin(t * Math.PI); +}; + +// Kick:极限单击——瞬速冲到 peak,之后强指数衰减 +const rhythmKick = (peak = 1.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.05) return peak * k / 0.05; + const t = (k - 0.05) / 0.95; + return peak * Math.exp(-4 * t); +}; + +// Crescendo:渐强——N 次高斯峰,间距递减、幅度递增 +const rhythmCrescendo = (beats = 4) => { + const centers = []; + for (let i = 0; i < beats; i++) { + const t = Math.pow((i + 1) / beats, 1.4); + centers.push({ c: Math.max(0.05, t - 0.08), w: 0.03, a: (i + 1) / beats }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return sum; + }; +}; + +// DunDunDun:悬疑递进——3 击幅度递增,末击更宽形成持续感 +const rhythmDunDunDun = () => { + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + return (k) => { + if (k <= 0 || k >= 1) return 0; + return 0.3 * bell(k, 0.15, 0.025) + + 0.6 * bell(k, 0.35, 0.03) + + 1.0 * bell(k, 0.68, 0.09); + }; +}; + +// BellToll:钟声——瞬间起振 + 指数衰减调幅的余弦振荡 +const rhythmBellToll = (decay = 3, freq = 8) => { + const strike = 0.05; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < strike) return k / strike; + const t = k - strike; + return Math.exp(-decay * t) * Math.cos(freq * Math.PI * t); + }; +}; + +const Rhythm = Object.freeze({ + BassDrop: rhythmBassDrop(), + PunchCombo: rhythmPunchCombo(), + Staccato: rhythmStaccato(), + Kick: rhythmKick(), + Crescendo: rhythmCrescendo(), + DunDunDun: rhythmDunDunDun(), + BellToll: rhythmBellToll(), +}); + +// ─── §17 UI 反馈 ─────────────────────────────────────────────────────────── + +// ClickSnap:按钮点击——压下(负偏移)→ 回弹微过冲 → 归零 +const uiClickSnap = (pressDepth = 0.3, reboundPeak = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.2) { + const t = k / 0.2; + return -pressDepth * Math.sin(t * Math.PI / 2); + } + if (k < 0.5) { + const t = (k - 0.2) / 0.3; + return -pressDepth + (pressDepth + reboundPeak) * (1 - Math.pow(1 - t, 3)); + } + const t = (k - 0.5) / 0.5; + return reboundPeak * Math.exp(-4 * t) * Math.cos(t * Math.PI * 3); +}; + +// HoverBloom:悬停高亮——梯形包络(快升 → plateau → 快降) +const uiHoverBloom = (riseRatio = 0.2, fallRatio = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return 1 - Math.pow(1 - t, 3); + } + if (k < 1 - fallRatio) return 1; + const t = (k - (1 - fallRatio)) / fallRatio; + return Math.pow(1 - t, 3); +}; + +// ErrorShake:错误反馈——方波化高频 shake +const uiErrorShake = (amplitude = 0.15, count = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + const raw = Math.sin(k * Math.PI * 2 * count); + const clipped = Math.sign(raw) * Math.min(1, Math.abs(raw) * 1.8); + return amplitude * env * clipped; +}; + +// SuccessPop:成功庆祝——瞬速 scale 到 1.2 → 阻尼余弦回到 1 +const uiSuccessPop = (overshoot = 0.2) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return (1 + overshoot) * (1 - Math.pow(1 - t, 2)); + } + const t = (k - 0.4) / 0.6; + return 1 + overshoot * Math.exp(-5 * t) * Math.cos(t * Math.PI * 3); +}; + +// RippleOut:Material 点击涟漪——早峰后淡出 +const uiRippleOut = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 6.75 * k * Math.pow(1 - k, 2); +}; + +const UI = Object.freeze({ + ClickSnap: uiClickSnap(), + HoverBloom: uiHoverBloom(), + ErrorShake: uiErrorShake(), + SuccessPop: uiSuccessPop(), + RippleOut: uiRippleOut(), +}); + +// ─── §18 Magic 能量 / 魔法 ───────────────────────────────────────────────── + +// ManaCharge:魔法蓄能——指数积蓄 + 高频 pulses +const magicManaCharge = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const base = (Math.exp(3 * k) - 1) / (Math.exp(3) - 1); + const pulse = 0.04 * Math.sin(k * Math.PI * 8) * k; + return base + pulse; +}; + +// SpellCast:施法——蓄能 + 瞬冲 1 + 拖尾衰减 +const magicSpellCast = (chargeEnd = 0.4) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < chargeEnd) { + const t = k / chargeEnd; + return 0.3 * Math.pow(t, 2) * (1 + 0.2 * Math.sin(t * Math.PI * 6)); + } + if (k < chargeEnd + 0.1) { + const t = (k - chargeEnd) / 0.1; + return 0.3 + 0.7 * t; + } + const t = (k - chargeEnd - 0.1) / (1 - chargeEnd - 0.1); + return Math.exp(-2 * t) * (1 + 0.1 * Math.cos(t * Math.PI * 4)); +}; + +// Teleport:瞬移——加速压缩 → 完全消失(平顶 1)→ 加速重现 +const magicTeleport = () => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.45) { + const t = k / 0.45; + return t * t * t; + } + if (k < 0.55) return 1; + const t = (k - 0.55) / 0.45; + return Math.pow(1 - t, 3); +}; + +// Shield:护盾——波纹扩散过冲到 1.2 → 稳定到 1 → 微脉动 +const magicShield = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.3) { + const t = k / 0.3; + return 1.2 * (1 - Math.pow(1 - t, 2)); + } + if (k < 0.6) { + const t = (k - 0.3) / 0.3; + return 1.2 - 0.2 * t; + } + const t = (k - 0.6) / 0.4; + return 1 + 0.03 * Math.sin(t * Math.PI * 3); +}; + +// MagicAura:魔法光环——基频 + 2 次谐波 + 3 次泛音的正弦叠加 +const magicAura = (peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const fundamental = 0.6 * Math.sin(k * Math.PI * 2); + const harmonic = 0.3 * Math.sin(k * Math.PI * 4 + 1); + const overtone = 0.1 * Math.sin(k * Math.PI * 6 + 2); + return peak * env * (fundamental + harmonic + overtone); +}; + +const Magic = Object.freeze({ + ManaCharge: magicManaCharge(), + SpellCast: magicSpellCast(), + Teleport: magicTeleport(), + Shield: magicShield(), + MagicAura: magicAura(), +}); + +// ─── §19 Animal 动物动作 ─────────────────────────────────────────────────── + +// CatPounce:猫扑击——蹲伏蓄力 + 起跳 + 空中抛物线 + 落地微压 +const animalCatPounce = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.2) { + const t = k / 0.2; + return -0.2 * Math.sin(t * Math.PI); + } + if (k < 0.3) { + const t = (k - 0.2) / 0.1; + return 0.5 * t * t; + } + if (k < 0.8) { + const t = (k - 0.3) / 0.5; + return 0.5 + 0.5 * t + 0.2 * Math.sin(t * Math.PI); + } + const t = (k - 0.8) / 0.2; + return 1 + 0.05 * Math.sin(t * Math.PI); +}; + +// BirdFlap:翅膀拍打——不对称基波(下扑快、上挥慢)+ sin 包络 +const animalBirdFlap = (flaps = 4) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const phase = k * Math.PI * 2 * flaps; + const wave = Math.sin(phase) - 0.3 * Math.sin(phase * 2); + return 0.2 * env * wave; +}; + +// SnakeSlither:蛇蜿蜒——连续 S 波 +const animalSnakeSlither = (waves = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const wave = Math.sin(k * Math.PI * 2 * waves); + return 0.2 * env * wave; +}; + +// ButterflyFlit:蝴蝶乱飞——seed 可复现的随机采样 + cubic 平滑插值 +const animalButterflyFlit = (seed = 13) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= 26; i++) samples.push(rand() - 0.5); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * 25; + const idx = Math.floor(pos); + const t = pos - idx; + const smooth = t * t * (3 - 2 * t); + const interp = samples[idx] + (samples[idx + 1] - samples[idx]) * smooth; + return 0.3 * env * interp; + }; +}; + +// HorseGallop:马奔驰——每周期 4 蹄击地 + 空中相位间隙 +const animalHorseGallop = (cycles = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const cyclePos = (k * cycles) - Math.floor(k * cycles); + const bell = (c, w = 0.04) => Math.exp(-((cyclePos - c) ** 2) / (2 * w * w)); + return 0.25 * env * (bell(0.0) + bell(0.18) + bell(0.36) + bell(0.54)); +}; + +const Animal = Object.freeze({ + CatPounce: animalCatPounce(), + BirdFlap: animalBirdFlap(), + SnakeSlither: animalSnakeSlither(), + ButterflyFlit: animalButterflyFlit(), + HorseGallop: animalHorseGallop(), +}); + +// ─── 导出(形态分类:Progress / Pulse / Wave) ───────────────────────────── +// +// 上方各主题常量(Physics / Motion / Step / Attention / Breath / Heart / +// MathExt / Explosion / Nature / Impact / Rhythm / UI / Magic / Animal) +// 及业界库 factory(libSpring / libSteps / libHeartBeat)仅作为 +// "源池"使用,不再作为顶层导出;由下列 Progress / Pulse / Wave 三个按形态 +// 分类的命名空间统一暴露。 +// +// 通用 UI 柔化(Smooth / Bezier 两组共 6 条命名曲线)已整组移除——数值上 +// 与原生 Sinusoidal/Quadratic/Cubic 等价;需定制贝塞尔请直接调用顶层 +// cubicBezier('Material.Standard' | x1,y1,x2,y2) 工厂。 + +// Progress —— 单调或衰减至 1 的曲线(A→B 过渡) +const Progress = Object.freeze({ + // Physics:原生 + Spring(Framer Motion 参数化弹簧) + Physics: Object.freeze({ + ...Physics, // SpringSoft / SpringStiff / DampedOscillation + Spring: libSpring(), // Framer Motion 风格默认弹簧 + }), + Motion, // Anticipate / Overshoot110 / Overshoot125 / SnapBack / Swing + // Step:固定段数实例 —— Steps4/6/8/12End 覆盖实用区间,无任意段数工厂 + Step: Object.freeze({ + ...Step, // Steps4End / Steps8End / Steps12End + Steps6: libSteps(), + }), + Math: Object.freeze({ + Tremor: MathExt.Tremor, + }), + Impact: Object.freeze({ + Rain: Impact.Rain, + Hammer: Impact.Hammer, + BounceDrop: Impact.BounceDrop, + ArrowHit: Impact.ArrowHit, + Shatter: Impact.Shatter, + }), + Rhythm: Object.freeze({ + BassDrop: Rhythm.BassDrop, + }), + UI: Object.freeze({ + SuccessPop: UI.SuccessPop, + }), + Magic: Object.freeze({ + ManaCharge: Magic.ManaCharge, + Shield: Magic.Shield, + }), + Animal: Object.freeze({ + CatPounce: Animal.CatPounce, + }), +}); + +// Pulse —— 单次返零脉冲(f(0)=f(1)=0, 单主峰;reversals ≤ 2 为主) +const Pulse = Object.freeze({ + Attention: Object.freeze({ + Ping: Attention.Ping, + }), + Breath: Object.freeze({ + Deep: Breath.Deep, + Sigh: Breath.Sigh, + }), + Heart: Object.freeze({ + Calm: Heart.Calm, + }), + Math: Object.freeze({ + JumpArc: MathExt.JumpArc, // 对称抛物 4k(1-k) + BoomerangSharp: mathBoomerang(E.Cubic.In), // 尖峰回程:缓→冲到峰→缓回(峰值锐利) + BoomerangSoft: mathBoomerang(E.Cubic.Out), // 平顶回程:快→在峰上停留→快回(峰值平滑) + }), + Explosion: Object.freeze({ + Impulse: Explosion.Impulse, + Flash: Explosion.Flash, + Recoil: Explosion.Recoil, + Implosion: Explosion.Implosion, + }), + Impact: Object.freeze({ + Slap: Impact.Slap, + }), + Rhythm: Object.freeze({ + Kick: Rhythm.Kick, + }), + UI: Object.freeze({ + ClickSnap: UI.ClickSnap, + HoverBloom: UI.HoverBloom, + RippleOut: UI.RippleOut, + }), + Magic: Object.freeze({ + SpellCast: Magic.SpellCast, + Teleport: Magic.Teleport, + }), +}); + +// Wave —— 周期多峰振荡(f(0)=f(1)=0, 多次反转) +const Wave = Object.freeze({ + Attention: Object.freeze({ + Wiggle: Attention.Wiggle, + Strum: Attention.Strum, + }), + Breath: Object.freeze({ + Normal: Breath.Normal, + Panting: Breath.Panting, + }), + Heart: Object.freeze({ + Excited: Heart.Excited, + LubDub: Heart.LubDub, + Beat: libHeartBeat(), // 迁移自 Lib.HeartBeat + }), + Math: Object.freeze({ + Pendulum: MathExt.Pendulum, + }), + Nature, // Wave / Flicker / Gust + Rhythm: Object.freeze({ + PunchCombo: Rhythm.PunchCombo, + Staccato: Rhythm.Staccato, + Crescendo: Rhythm.Crescendo, + DunDunDun: Rhythm.DunDunDun, + BellToll: Rhythm.BellToll, + }), + UI: Object.freeze({ + ErrorShake: UI.ErrorShake, + }), + Magic: Object.freeze({ + MagicAura: Magic.MagicAura, + }), + Animal: Object.freeze({ + BirdFlap: Animal.BirdFlap, + SnakeSlither: Animal.SnakeSlither, + ButterflyFlit: Animal.ButterflyFlit, + HorseGallop: Animal.HorseGallop, + }), +}); + +const customEasings = Object.freeze({ + makeOutIn, + OutIn, + Progress, + Pulse, + Wave, + cubicBezier, +}); + +exports.customEasings = customEasings; +exports.default = customEasings; diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..8642c5b96e62ccd27ab63ba9d26170c4e3bf2d07 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,800 @@ +/** + * 场景核心模块 + * + * 包含Three.js核心对象的创建和管理 + * 提供场景管理的核心功能:初始化、配置和更新 + */ + +// ThreeJS Env +// 导入TWEEN库 +// const TWEEN = require('../lib/tween'); +// 导入Three.js库 +// const THREE = require('three'); + + +// Effect Env +// 导入TWEEN库 +const TWEEN = require('./tween'); +// 导入自定义缓动函数库(OutIn 模式等官方未提供的组合) +const customEasings = require('./customEasings').customEasings; +// 导入Three.js 的 wrapper库 +const THREE = require('./three-amg-wrapper').THREE; +const { ShaderPass } = require('./ShaderPass.js'); +/** + * ScriptScene类 - 3D场景管理器 + * 负责创建和管理Three.js场景、相机、渲染器及场景对象 + */ +class ScriptScene { + /** + * 构造函数,创建场景管理器 + * @param {effect.Amaz.Scene} [amgScene] - AMG场景对象,可选参数 + * @param {HTMLElement} [container] - 放置渲染器的DOM容器,可选参数 + */ + constructor(amgScene = null, container = null) { + // 核心对象初始化 + if (amgScene) { + this.scene = new THREE.Scene(); + this.scene._amgScene = amgScene; + } else { + this.scene = new THREE.Scene(); + } + this.effect_type = "transition"; + this.camera = null; + this.renderer = null; + this.scene.background = new THREE.Color(0x333333); + this.isAnimating = false; + this.animationFrameId = null; + this.sceneObjects = null; + + this.texture1 = null; + this.texture2 = null; + + // 后处理相关属性 + this.composer = null; + this.renderPass = null; + this.usePostProcessing = true; // 是否启用后处理效果 + + // 初始化核心对象和基本场景 + this.initCoreObjects(); + if (container) { + this.init(container); + } + } + + /** + * 析构函数,清理场景并释放资源 + * 在不再需要场景时调用,确保正确释放内存和停止动画循环 + */ + destroy() { + // 停止动画循环 + this.isAnimating = false; + + // 取消动画帧请求 + if (this.animationFrameId !== null && typeof cancelAnimationFrame !== 'undefined') { + cancelAnimationFrame(this.animationFrameId); + this.animationFrameId = null; + } + + // 清理渲染器 + if (this.renderer) { + this.renderer.setAnimationLoop(null); + this.renderer.dispose(); + + // 移除渲染器的DOM元素 + if (this.renderer.domElement && this.renderer.domElement.parentNode) { + this.renderer.domElement.parentNode.removeChild(this.renderer.domElement); + } + } + + // 清理纹理资源 + if (this.texture1) { + if (typeof this.texture1.dispose === "function") this.texture1.dispose(); + this.texture1 = null; + } + if (this.texture2) { + if (typeof this.texture2.dispose === "function") this.texture2.dispose(); + this.texture2 = null; + } + + + + // 清理场景中的对象 + if (this.scene) { + this.scene.dispose(); + } + + // 移除窗口事件监听器 + if (typeof window !== 'undefined') { + window.removeEventListener('resize', this.handleResize); + } + + // 清理TWEEN动画 + if (this.sceneObjects && this.sceneObjects.tweens) { + this.sceneObjects.tweens.forEach(tween => { + if (tween && typeof tween.stop === 'function') { + tween.stop(); + } + }); + this.sceneObjects.tweens = []; + } + + // 清理多pass + if (this.shaderPasses && this.shaderPasses.length) { + this.shaderPasses.forEach((pass) => { + if (pass && typeof pass.dispose === "function") { + try { + pass.dispose(); + } catch (e) {} + } + }); + this.shaderPasses = []; + } + if (this.shaderPass && typeof this.shaderPass.dispose === "function") { + try { + this.shaderPass.dispose(); + } catch (e) {} + } + this.shaderPass = null; + // 清理后处理效果 + if (this.composer) { + this.composer.dispose(); + this.composer = null; + } + + this.renderPass = null; + + // 清理引用 + this.scene = null; + this.camera = null; + this.renderer = null; + this.sceneObjects = null; + } + + /** + * 初始化Three.js核心对象 + * 包括场景、相机和渲染器 + */ + initCoreObjects() { + if (typeof window !== "undefined") { + if (!window.innerWidth || !window.innerHeight) { + window.innerWidth = 600; + window.innerHeight = 600; + } + window.devicePixelRatio = window.devicePixelRatio || 1; + if (this.scene && this.scene._amgScene && this.scene._amgScene.assetMgr) { + const inputTexture = this.scene._amgScene.assetMgr.SyncLoad("share://input.texture"); + if (inputTexture && inputTexture.width > 0 && inputTexture.height > 0) { + window.innerWidth = inputTexture.width; + window.innerHeight = inputTexture.height; + } + } + } + this.camera = new THREE.PerspectiveCamera( + 53.1, // 视场角 + window.innerWidth / window.innerHeight, // 纵横比 + 0.1, // 近平面 + 10000 // 远平面 + ); + this.camera.position.z = 10; // 设置默认相机位置 + this.scene.add(this.camera); + + // 创建渲染器,启用抗锯齿 + // 当amgScene为null时,创建渲染器 + if (this.scene._amgScene == null) + { + this.renderer = new THREE.WebGLRenderer({ antialias: true }); + this.renderer.outputColorSpace = THREE.LinearSRGBColorSpace; + } + if (this.renderer) + { + this.renderer.setSize(window.innerWidth, window.innerHeight); + this.renderer.setPixelRatio(window.devicePixelRatio); + } + + // 滑竿列表 + this.sliders = {}; + + // 创建TWEEN实例 + this.TWEEN = TWEEN; + // 自定义缓动函数库:使用方式 this.customEasings.OutIn.Back 等 + this.customEasings = customEasings; + + // 时长 毫秒 + this.Duration = 2000; + } + + /** + * 添加ShaderPass + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + addShaderPass(shaderPassConfigs) { + if (!Array.isArray(shaderPassConfigs)) { + shaderPassConfigs = [shaderPassConfigs]; + } + + shaderPassConfigs.forEach(config => { + const atomicName = config.name; + const className = atomicName.startsWith('Lumi') ? atomicName.substring(4) : atomicName; + const shaderPassModule = require('../pp/Lumi' + className + '/' + className + 'ShaderPass.js'); + const ShaderPassClass = shaderPassModule[className + 'ShaderPass']; + const initConfig = (config && (config.initConfig || config.config || config.params)) || {}; + const shaderPass = new ShaderPassClass(initConfig); + // console.log('ShaderPass created:', shaderPass, className); + this.composer.addPass(shaderPass); + this.shaderPasses.push(shaderPass); + }); + } + + /** + * 设置后处理 + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + setupPostProcessing(shaderPassConfigs) { + const { EffectComposer } = require('./EffectComposer.js'); + const { RenderPass } = require('./RenderPass.js'); + + // 创建后处理渲染目标 + this.composer = new EffectComposer(this.renderer); + this.renderPass = new RenderPass(this.scene, this.camera); + this.composer.addPass(this.renderPass); + this.shaderPasses = []; + + this.addShaderPass(shaderPassConfigs); + } + +//===begin_pp=== +initPostProcessing() {} +//===end_pp=== + + /** + * 初始化场景 + * 设置基本的Three.js环境,添加渲染器到DOM + * @param {HTMLElement} container - 放置渲染器的DOM容器 + */ + init(container) { + if (this.renderer) { + if (container) { + container.appendChild(this.renderer.domElement); + } else if (typeof document !== 'undefined') { + document.body.appendChild(this.renderer.domElement); + } + } + if (typeof window !== 'undefined') { + window.addEventListener('resize', () => this.handleResize()); + } + } + + /** + * 开始场景动画循环 + * @param {Function} updateCallback - 每帧调用的更新函数 + */ + start(updateCallback) { + if (this.isAnimating) return; + + this.isAnimating = true; + + // 如果提供了更新回调,使用requestAnimationFrame + if (updateCallback) { + const animateFrame = () => { + if (!this.isAnimating) return; + updateCallback(); + this.animationFrameId = requestAnimationFrame(animateFrame); + }; + + animateFrame(); + } else { + // 否则使用Three.js的setAnimationLoop,直接调用update渲染场景 + this.renderer.setAnimationLoop(() => { + this.update(); + }); + } + } + + + + /** + * 更新场景(由外部动画循环调用) + * @param {number} timestamp - 当前时间戳 + */ + updateScene(timestamp) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 直接调用默认更新函数,传入时间戳 + this.defaultUpdate(timestamp); + } + + /** + * 更新并渲染场景 + * 在每一帧调用,将当前场景通过渲染器绘制到屏幕 + */ + update() { + if (this.usePostProcessing && this.composer) { + // 确保composer使用当前活动的相机 + if (this.renderPass) { + this.renderPass.camera = this.camera; + } + + // 使用后处理效果渲染 + this.composer.render(); + } else if (this.renderer) { + // 直接渲染场景 + this.renderer.render(this.scene, this.camera); + } + } + + /** + * 窗口大小调整处理 + * 在窗口大小变化时调整相机和渲染器 + */ + handleResize() { + this.camera.aspect = window.innerWidth / window.innerHeight; + this.camera.updateProjectionMatrix(); + if (this.renderer) { + this.renderer.setSize(window.innerWidth, window.innerHeight); + } + + // 调整后处理效果的大小 + // if (this.composer) { + // this.composer.setSize(window.innerWidth, window.innerHeight); + // } + + // 如果不在动画循环中,触发一次渲染以更新视图 + if (!this.isAnimating) { + this.update(); + } + } + + loadTextures() { + const textureLoader = new THREE.TextureLoader(); + return Promise.all([ + new Promise(resolve => { + this.texture1 = textureLoader.load('image/Sample1.jpg', resolve); + this.texture1.colorSpace = THREE.LinearSRGBColorSpace; + this.texture1.wrapS = THREE.RepeatWrapping; + this.texture1.wrapT = THREE.RepeatWrapping; + }), + new Promise(resolve => { + this.texture2 = textureLoader.load('image/Sample2.jpg', resolve); + this.texture2.colorSpace = THREE.LinearSRGBColorSpace; + this.texture2.wrapS = THREE.RepeatWrapping; + this.texture2.wrapT = THREE.RepeatWrapping; + }) + ]); + } + + _applyTweenInitialState(tween) { + if (!tween._propertiesAreSetUp) { + tween.start(0); + } + if (!tween._valuesStart || !tween._valuesEnd) { + return; + } + tween._updateProperties(tween._object, tween._valuesStart, tween._valuesEnd, 0); + if (typeof tween._onUpdateCallback === 'function') { + tween._onUpdateCallback(tween._object, 0); + } + } + + _applyTweenFinalState(tween) { + if (!tween._propertiesAreSetUp) { + tween.start(0); + } + if (!tween._valuesStart || !tween._valuesEnd) { + return; + } + tween._updateProperties(tween._object, tween._valuesStart, tween._valuesEnd, 1); + if (typeof tween._onUpdateCallback === 'function') { + tween._onUpdateCallback(tween._object, 1); + } + } + + /** + * 根据时间直接设置动画状态(用于时间跳转) + * @param {number} time - 动画时间(毫秒) + */ + seekToTime(time) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 限制时间范围 + const clampedTime = Math.max(0, Math.min(time, this.Duration)); + + // seek ShaderPass后处理逻辑,该函数已预先定义,无需生成_predef_seekShaderPass实现 + if (this._predef_seekShaderPass) + { + this._predef_seekShaderPass(clampedTime); + } + + if (!this.sceneObjects.tweens || this.sceneObjects.tweens.length === 0) { + return; + } + + // 使用逆序遍历 TWEEN,确保正确的属性覆盖优先级 + // 逆序处理:让开始时间晚的tween先处理,开始时间早的tween后处理并覆盖 + + let notStartTweens = []; + let runningTweens = []; + let finishedTweens = []; + + for (let i = 0; i <= this.sceneObjects.tweens.length - 1; i++) { + const tween = this.sceneObjects.tweens[i]; + + let TweenStartTime = tween._delayTime + 10; + let TweenEndTime = tween._delayTime + tween._duration; + + // 将tween分为三种,未开始,进行中,已结束 + // 分到3个列表中 + + if (clampedTime <= TweenStartTime) { + notStartTweens.push({time: TweenStartTime, tween: tween}); + } + else if (clampedTime >= TweenEndTime) { + finishedTweens.push({time: TweenEndTime, tween: tween}); + } + else + { + runningTweens.push(tween); + } + } + + // 按照开始时间排序 + notStartTweens.sort((a, b) => b.time - a.time); + // 按照结束时间排序 + finishedTweens.sort((a, b) => a.time - b.time); + + notStartTweens.forEach(item => { + this._applyTweenInitialState(item.tween); + }); + + finishedTweens.forEach(item => { + this._applyTweenFinalState(item.tween); + }); + + runningTweens.forEach(tween => { + tween.stop(); + tween.start(0); + tween.update(clampedTime); + }); + + this.update(); + } + +//===begin=== +//===滑竿begin=== +//===滑竿end=== +/** + * 初始化滑竿 + */ +setupSliders(){ +} + +/** + * 更新滑竿 + */ +updateSliders(){ +} + +/** + * 初始化一个完整的基本场景(不包含动画循环) + * 包括相机、场景对象的创建和特效材质 + * @returns {Object} 场景中的对象引用 + */ +setupScene() { + // 初始化场景对象容器 + this.initSceneObjects(); + + // 更新滑竿 + this.setupSliders(); + this.updateSliders(); + + // 设置场景背景为黑色 + this.scene.background = new THREE.Color(0x000000); + + // 创建效果平面 + this.createPlane(); + + // 设置动画 + this.setupAnimation(); + + return this.sceneObjects; +} + +/** + * 初始化场景对象容器 + */ +initSceneObjects() { + this.sceneObjects = { + plane: null, // 主平面对象 + material: null, // 效果材质 + tweens: [] // 动画对象数组 + }; +} + +/** + * 创建效果平面 + */ +createPlane() { + // 创建平面几何体,宽高比为1:1 + const geometry = new THREE.PlaneGeometry(10, 10, 100, 1); + + // 使用自定义着色器材质实现扫描线效果 + const material = this.createMaterial(); + this.sceneObjects.material = material; + + // 创建面片 + const plane = new THREE.Mesh(geometry, material); + plane.name = "Plane"; + this.sceneObjects.plane = plane; + + // 将面片添加到场景 + this.scene.add(plane); +} + +/** + * 创建效果平面的着色器材质 + * @returns {THREE.ShaderMaterial} 效果平面着色器材质 + */ +createMaterial() { + // 确保纹理已加载 + if (!this.texture1 || !this.texture2) { + console.error("纹理未加载!"); + return new THREE.MeshBasicMaterial({ color: 0xff0000 }); + } + + // 为纹理设置适当的参数 + this.texture1.minFilter = THREE.LinearFilter; + this.texture1.magFilter = THREE.LinearFilter; + this.texture1.wrapS = THREE.ClampToEdgeWrapping; + this.texture1.wrapT = THREE.ClampToEdgeWrapping; + + this.texture2.minFilter = THREE.LinearFilter; + this.texture2.magFilter = THREE.LinearFilter; + this.texture2.wrapS = THREE.ClampToEdgeWrapping; + this.texture2.wrapT = THREE.ClampToEdgeWrapping; + + // 创建自定义着色器材质 + this.shaderPass = new (require('../pp/LumiCustom/CustomShaderPass.js').CustomShaderPass)(); + var material = this.shaderPass.material; + // 传入默认纹理 + material.uniforms.tDiffuse.value = this.texture1; + material.uniforms.tDiffuse1.value = this.texture2; + return material; +} + +/** + * 设置动画 + */ +setupAnimation() { + if (!this.shaderPass) { + console.error("着色器传递对象未创建!"); + return; + } + if (typeof this.shaderPass.setParameter !== 'function') { + console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`); + return; + } + + const duration = this.Duration; // 使用已定义的持续时间 + const tweens = []; + this.sceneObjects.tweens = []; + + // 创建从0到1的动画 + const tween1 = new TWEEN.Tween({ intensity: 0, progress: 0 }) + .to({ intensity: 1, progress: 0.5 }, duration * 0.35) + .delay(duration * 0.15) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历obj中的所有属性,自动设置参数 + for (const key in obj) { + this.shaderPass.setParameter(key, obj[key]); + } + }); + + // 创建从1到0的动画 + const tween2 = new TWEEN.Tween({ intensity: 1, progress: 0.5 }) + .to({ intensity: 0, progress: 1 }, duration * 0.35) + .delay(duration * 0.5) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历obj中的所有属性,自动设置参数 + for (const key in obj) { + this.shaderPass.setParameter(key, obj[key]); + } + }); + + tweens.push(tween1, tween2); + + // 启动所有动画 + tweens.forEach(tween => tween.start()); + + // 存储动画对象引用 + if (tweens.length > 0) { + if (!this.sceneObjects.tweens) { + this.sceneObjects.tweens = []; + } + this.sceneObjects.tweens.push(...tweens); + } +} +//===end=== + + /** + * 默认的场景更新函数,实现轨道交错转场动画 + */ + defaultUpdate(timestamp) { + // 更新所有TWEEN动画 + if (this.sceneObjects.tweens && this.sceneObjects.tweens.length > 0) { + this.sceneObjects.tweens.forEach(tween => { + if (tween && typeof tween.update === 'function') { + tween.update(timestamp); + } + }); + } + + this.update(); + } + + //===Predefined Function Begin=== +_predef_addTopCenterBottomStyleBorder(parent, offset, texture, cutoutAreaPosition, cutoutAreaSize) { + const aspectRatio = this.texture1.image.width / this.texture1.image.height; + const parentInitScale = parent.scale.y; + const parentPosition = parent.position; + const textureWidth = texture.image.width; + const textureHeight = texture.image.height; + const geometry = new THREE.PlaneGeometry(10, 10); + + // center + const textureCenter = texture.clone(); + textureCenter.repeat.set(1, cutoutAreaSize.y / textureHeight); + textureCenter.offset.set(0, (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureHeight); + + const materialCenter = new THREE.MeshBasicMaterial({ + map: textureCenter, + transparent: true, + opacity: 1, + premultipliedAlpha: true, + side: THREE.DoubleSide + }); + materialCenter.name = 'PlaneCenterMaterial'; + + const planeCenter = new THREE.Mesh(geometry, materialCenter); + planeCenter.name = 'PlaneCenter'; + planeCenter.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y, parentPosition.z + offset.z); + planeCenter.scale.set(parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth), parentInitScale, 1); + + this.scene.add(planeCenter); + parent.attach(planeCenter); + + // top + const textureTop = texture.clone(); + textureTop.repeat.set(1, cutoutAreaPosition.y / textureHeight); + textureTop.offset.set(0, 1 - cutoutAreaPosition.y / textureHeight); + + const materialTop = new THREE.MeshBasicMaterial({ + map: textureTop, + transparent: true, + opacity: 1, + premultipliedAlpha: true, + side: THREE.DoubleSide + }); + materialTop.name = 'PlaneTopMaterial'; + + const scaleXTop = parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth); + const scaleYTop = scaleXTop * cutoutAreaPosition.y / textureWidth; + + const planeTop = new THREE.Mesh(geometry, materialTop); + planeTop.name = 'PlaneTop'; + planeTop.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y + parentInitScale * 10 * 0.5 + scaleYTop * 10 * 0.5, parentPosition.z + offset.z); + planeTop.scale.set(scaleXTop, scaleYTop, 1); + + this.scene.add(planeTop); + parent.attach(planeTop); + + // bottom + const textureBottom = texture.clone(); + textureBottom.repeat.set(1, (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureHeight); + textureBottom.offset.set(0, 0); + + const materialBottom = new THREE.MeshBasicMaterial({ + map: textureBottom, + transparent: true, + opacity: 1, + premultipliedAlpha: true, + side: THREE.DoubleSide + }); + materialBottom.name = 'PlaneBottomMaterial'; + + const scaleXBottom = parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth); + const scaleYBottom = scaleXBottom * (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureWidth; + + const planeBottom = new THREE.Mesh(geometry, materialBottom); + planeBottom.name = 'PlaneBottom'; + planeBottom.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y - parentInitScale * 10 * 0.5 - scaleYBottom * 10 * 0.5, parentPosition.z + offset.z); + planeBottom.scale.set(scaleXBottom, scaleYBottom, 1); + + this.scene.add(planeBottom); + parent.attach(planeBottom); +} +_predef_loadVideoTexture(path, loop, playbackRate) { + if (this.scene._amgScene == null) { + const video = document.createElement('video'); + video.src = path; + video.muted = true; + video.loop = loop; + //video.play(); + video.load(); + + // video.style.position = 'absolute'; + // video.style.top = '400px'; + // video.style.left = '0px'; + // video.style.width = '480px'; + // video.style.height = '360px'; + // video.style.zIndex = '100'; + // document.body.appendChild(video); + + const videoTexture = new THREE.VideoTexture(video); + videoTexture.currentTime = 0; + videoTexture.playbackRate = playbackRate; + + this.videoTexture = videoTexture; + + return videoTexture; + } else if (typeof this.scene._amgScene === 'string') { + return new THREE.Texture(); + } else { + const texture = new THREE.VideoTexture(path, loop, playbackRate); + texture.load(); + return texture; + } +} +_predef_seekVideoTexture(time) { + if (this.videoTexture != null) { + const videoTexture = this.videoTexture; + const video = videoTexture.image; + if (video.readyState >= 2) { + const textureProperties = this.renderer.properties.get(videoTexture); + var newTime = time / 1000 * videoTexture.playbackRate; + if (newTime < 0) { + newTime = 0; + } else if (newTime > video.duration) { + if (video.loop) { + newTime = newTime % video.duration; + } else { + newTime = video.duration; + } + } + if (textureProperties.__version == videoTexture.version) { + videoTexture.currentTime = newTime; + video.currentTime = videoTexture.currentTime; + } + } + } +} +_predef_seekShaderPass(time) { + if (!('shaderPasses' in this) || this.shaderPasses == null) { + return; + } + this.shaderPasses.forEach(shaderPass => { + if (shaderPass.constructor.name === 'AnimSeqLoadAndCropBlendShaderPass') { + if (this.texture1 && this.texture1.image) { + const ratio = this.texture1.image.width / this.texture1.image.height; + if (typeof shaderPass.setAspectRatio === 'function') { + shaderPass.setAspectRatio(ratio); + } + } + } + }) +}//===Predefined Function End=== +} + +// 导入Three.js库 +// module.exports = ScriptScene; + +// 导入Three.js 的 wrapper库 +exports.ScriptScene = ScriptScene; diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..a5fd4883bac974897a1c16105d092d5a770bfa4c --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1,399 @@ +/** + * ThreeJS 到 AMG 的包装器 + * 让基于ThreeJS开发的应用能够在AMG引擎上运行 + * 此包装器将ThreeJS的API转换为AMG引擎的调用,实现无缝迁移 + */ + +// 获取AMG引擎API +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz ? effect_api.getAmaz() : null; + +// 场景实例存取模块 +const { getCurrentScene, setCurrentScene, clearCurrentScene } = require('./wrapper/runtime'); + +// 模拟浏览器环境中的window对象,使ThreeJS代码能在非浏览器环境中运行 +if (typeof window === 'undefined') { + // 定义模拟的window对象 + const mockWindow = { + innerWidth: 720, + innerHeight: 1280, + devicePixelRatio: 1, + addEventListener: function(event, callback) { + // 空函数,模拟事件监听 + }, + requestAnimationFrame: function(callback) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + cancelAnimationFrame: function(id) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + removeEventListener: function(event, callback) { + // 空实现 + // 在实际环境中应该取消事件监听 + } + }; + + // 定义模拟的document对象 + const mockDocument = { + createElement: function(tagName) { + return { + style: {}, + setAttribute: function() {}, + appendChild: function() {} + }; + }, + body: { + appendChild: function() {} + } + }; + + // 获取全局对象的通用方法 + const getGlobalObject = function() { + if (typeof global !== 'undefined') return global; + if (typeof self !== 'undefined') return self; + if (typeof window !== 'undefined') return window; + if (typeof this !== 'undefined') return this; + return {}; // 回退选项 + }; + + // 将模拟对象挂载到全局 + const globalObj = getGlobalObject(); + globalObj.window = mockWindow; + globalObj.document = mockDocument; + globalObj.cancelAnimationFrame = mockWindow.cancelAnimationFrame; +} + +// 定义命名空间对象,类似于THREE +const THREE = {}; + +// 常量定义(从 wrapper/Constants 统一导入,避免重复定义) +const __THREE_CONSTS = require('./wrapper/Constants'); + +THREE.FrontSide = __THREE_CONSTS.FrontSide; +THREE.BackSide = __THREE_CONSTS.BackSide; +THREE.DoubleSide = __THREE_CONSTS.DoubleSide; +THREE.NoBlending = __THREE_CONSTS.NoBlending; +THREE.NormalBlending = __THREE_CONSTS.NormalBlending; +THREE.AdditiveBlending = __THREE_CONSTS.AdditiveBlending; +THREE.SubtractiveBlending = __THREE_CONSTS.SubtractiveBlending; +THREE.MultiplyBlending = __THREE_CONSTS.MultiplyBlending; +THREE.CustomBlending = __THREE_CONSTS.CustomBlending; +THREE.RepeatWrapping = __THREE_CONSTS.RepeatWrapping; +THREE.ClampToEdgeWrapping = __THREE_CONSTS.ClampToEdgeWrapping; +THREE.MirroredRepeatWrapping = __THREE_CONSTS.MirroredRepeatWrapping; + + + +const Vector2Wrapper = require('./wrapper/Vector2').Vector2; +const Vector3Wrapper = require('./wrapper/Vector3').Vector3; +const Vector4Wrapper = require('./wrapper/Vector4').Vector4; +const EulerWrapper = require('./wrapper/Euler').Euler; +const ColorWrapper = require('./wrapper/Color').Color; +const Matrix4Wrapper = require('./wrapper/Matrix4').Matrix4; +const QuaternionWrapper = require('./wrapper/Quaternion').Quaternion; +const MathUtilsWrapper = require('./wrapper/MathUtils').MathUtils; +const Box3Wrapper = require('./wrapper/Box3').Box3; +const Box2Wrapper = require('./wrapper/Box2').Box2; +const WebGLRendererWrapper = require('./wrapper/WebGLRenderer').WebGLRenderer; + +const Vector2 = Vector2Wrapper; +const Vector3 = Vector3Wrapper; +const Vector4 = Vector4Wrapper; +const Euler = EulerWrapper; +const Color = ColorWrapper; +const Matrix4 = Matrix4Wrapper; +const Quaternion = QuaternionWrapper; +const MathUtils = MathUtilsWrapper; +const Box3 = Box3Wrapper; +const Box2 = Box2Wrapper; +const WebGLRenderer = WebGLRendererWrapper; + + +const BufferGeometryWrapper = require('./wrapper/BufferGeometry').BufferGeometry; +const BufferAttributeWrapper = require('./wrapper/BufferAttribute').BufferAttribute; +const BoxGeometryWrapper = require('./wrapper/BoxGeometry').BoxGeometry; +const PlaneGeometryWrapper = require('./wrapper/PlaneGeometry').PlaneGeometry; +const SphereGeometryWrapper = require('./wrapper/SphereGeometry').SphereGeometry; +const CylinderGeometryWrapper = require('./wrapper/CylinderGeometry').CylinderGeometry; +const CapsuleGeometryWrapper = require('./wrapper/CapsuleGeometry').CapsuleGeometry; +const ShapeWrapper = require('./wrapper/Shape').Shape; +const ShapeGeometryWrapper = require('./wrapper/ShapeGeometry').ShapeGeometry; +const ExtrudeGeometryWrapper = require('./wrapper/ExtrudeGeometry').ExtrudeGeometry; +const CurvePathWrapper = require('./wrapper/CurvePath').CurvePath; +const LineCurveWrapper = require('./wrapper/CurvePath').LineCurve; + +const BufferGeometry = BufferGeometryWrapper; +const BufferAttribute = BufferAttributeWrapper; +const BoxGeometry = BoxGeometryWrapper; +const PlaneGeometry = PlaneGeometryWrapper; +const SphereGeometry = SphereGeometryWrapper; +const CylinderGeometry = CylinderGeometryWrapper; +const CapsuleGeometry = CapsuleGeometryWrapper; +const Shape = ShapeWrapper; +const ShapeGeometry = ShapeGeometryWrapper; +const ExtrudeGeometry = ExtrudeGeometryWrapper; +const CurvePath = CurvePathWrapper; +const LineCurve = LineCurveWrapper; + +const TextureWrapper = require('./wrapper/Texture').Texture; +const VideoTextureWrapper = require('./wrapper/Texture').VideoTexture; +const TextureLoaderWrapper = require('./wrapper/Texture').TextureLoader; + +const Texture = TextureWrapper; +const VideoTexture = VideoTextureWrapper; +const TextureLoader = TextureLoaderWrapper; + + +const MaterialWrapper = require('./wrapper/Material').Material; +const MeshBasicMaterialWrapper = require('./wrapper/MeshBasicMaterial').MeshBasicMaterial; +const ShaderMaterialWrapper = require('./wrapper/ShaderMaterial').ShaderMaterial; + +const Material = MaterialWrapper; +const MeshBasicMaterial = MeshBasicMaterialWrapper; +const ShaderMaterial = ShaderMaterialWrapper; + + +const Object3DWrapper = require('./wrapper/Object3D').Object3D; +const GroupWrapper = require('./wrapper/Group').Group; +const MeshWrapper = require('./wrapper/Mesh').MeshWrapper; +const PerspectiveCameraWrapper = require('./wrapper/PerspectiveCamera').PerspectiveCamera; + +const Object3D = Object3DWrapper; +const Group = GroupWrapper; +const Mesh = MeshWrapper; +const PerspectiveCamera = PerspectiveCameraWrapper; +/** + * 场景类 + * 管理场景中的所有对象 + */ +class Scene { + constructor() { + // this._amgScene = new Amaz.Scene(); + this._objects = []; + + // 将场景添加到AMG管理器 + // effect.Amaz.AmazingManager.addScene(this._amgScene); + + // 设置全局场景实例 + setCurrentScene(this); + + console.log('AMG scene created'); + } + + /** + * 添加对象到场景 + * 支持一次添加多个对象,如: scene.add(obj1, obj2, obj3) + * @param {...Object} objects - 要添加的对象(可变参数) + */ + add(...objects) { + // 遍历所有传入的对象 + for (let i = 0; i < objects.length; i++) { + const object = objects[i]; + + if (!object) { + console.warn('Scene: 尝试添加空对象'); + continue; + } + + if (object._amgEntity) { + if (this._objects.indexOf(object) === -1) { + this._objects.push(object); + if (this._amgScene) { + if (object._transform.parent) { + object._transform.parent.removeTransform(object._transform); + } + object._transform.parent = null; + this._amgScene.addEntity(object._amgEntity); + } + console.log('Scene: added object to scene:', object._amgEntity.name); + } + else { + console.log('Scene: object already exists:', object._amgEntity.name); + } + } else { + console.warn('Scene: 添加到场景的对象没有_amgEntity属性'); + } + } + } + + /** + * 从场景中移除对象,不删除AMG实体 + * @param {Object} object - 要移除的对象 + */ + remove(object) { + const index = this._objects.indexOf(object); + if (index !== -1) { + this._objects.splice(index, 1); + console.log('Scene: removed object from scene, not delete AMG entity.'); + } + } + + /** + * 从场景中删除对象,删除AMG实体 + */ + delete(object) { + const index = this._objects.indexOf(object); + if (index !== -1) { + this._objects.splice(index, 1); + if (object._amgEntity) { + this._amgScene.removeEntity(object._amgEntity); + } + console.log('Scene: delete object from scene, delete AMG entity.'); + } + } + + /** + * 更新场景中的所有对象 + */ + update() { + // 更新场景中的所有对象 + this._objects.forEach(obj => obj.update && obj.update()); + } + + seekToTime(time) { + this._objects.forEach(obj => obj.seekToTime && obj.seekToTime(time)); + } + + /** + * 析构函数,清理场景资源 + * 在不再需要场景时调用,确保释放所有资源并从AMG管理器中移除 + */ + dispose() { + console.log('Scene: 开始清理场景资源'); + + // 清理所有对象 + while (this._objects.length > 0) { + const object = this._objects[0]; + this.delete(object); + + // 如果对象有自己的dispose方法,调用它 + if (object.dispose && typeof object.dispose === 'function') { + object.dispose(); + } + + // 释放几何体和材质 + if (object.geometry && object.geometry.dispose) { + object.geometry.dispose(); + } + + if (object.material) { + if (Array.isArray(object.material)) { + object.material.forEach(material => { + if (material.dispose) material.dispose(); + }); + } else if (object.material.dispose) { + object.material.dispose(); + } + } + } + + // 从AMG管理器中移除场景 + if (this._amgScene) { + this._amgScene = null; + } + + // 清空对象数组 + this._objects = []; + + // 如果当前全局场景是这个场景,重置它 + if (getCurrentScene() === this) { + clearCurrentScene(); + } + + console.log('Scene: 场景资源清理完成'); + } +} + +class QuadraticBezierCurve3 { + constructor(p0, p1, p2) { + this.p0 = p0; + this.p1 = p1; + this.p2 = p2; + } + + getPoint(t) { + // 二次贝塞尔曲线公式: B(t) = (1-t)²P₀ + 2(1-t)tP₁ + t²P₂ + const u = 1 - t; + const tt = t * t; + const uu = u * u; + const ut2 = 2 * u * t; + + return new Vector3( + uu * this.p0.x + ut2 * this.p1.x + tt * this.p2.x, + uu * this.p0.y + ut2 * this.p1.y + tt * this.p2.y, + uu * this.p0.z + ut2 * this.p1.z + tt * this.p2.z + ); + } + + getPoints(divisions) { + const points = []; + for (let i = 0; i <= divisions; i++) { + points.push(this.getPoint(i / divisions)); + } + return points; + } +} + + +/** #region 基础数学与类型 */ +THREE.Vector2 = Vector2; +THREE.Vector3 = Vector3; +THREE.Vector4 = Vector4; +THREE.Euler = Euler; +THREE.Color = Color; +THREE.Matrix4 = Matrix4; +THREE.Quaternion = Quaternion; +THREE.QuadraticBezierCurve3 = QuadraticBezierCurve3; +THREE.Box3 = Box3; +THREE.Box2 = Box2; +THREE.MathUtils = MathUtils; +/** #endregion 基础数学与类型 */ + +/** #region 场景与相机 */ +THREE.Scene = Scene; +/** #endregion 场景与相机 */ + +/** #region 渲染器 */ +THREE.WebGLRenderer = WebGLRenderer; +/** #endregion 渲染器 */ + +/** #region 几何体与属性 */ +THREE.BufferGeometry = BufferGeometry; +THREE.BufferAttribute = BufferAttribute; +THREE.Float32BufferAttribute = BufferAttribute; +THREE.BoxGeometry = BoxGeometry; +THREE.PlaneGeometry = PlaneGeometry; +THREE.SphereGeometry = SphereGeometry; +THREE.CylinderGeometry = CylinderGeometry; +THREE.CapsuleGeometry = CapsuleGeometry; +THREE.Shape = Shape; +THREE.ShapeGeometry = ShapeGeometry; +THREE.ExtrudeGeometry = ExtrudeGeometry; +THREE.CurvePath = CurvePath; +THREE.LineCurve = LineCurve; +/** #endregion 几何体与属性 */ + +/** #region 材质与着色 */ +THREE.Material = Material; +THREE.MeshBasicMaterial = MeshBasicMaterial; +THREE.ShaderMaterial = ShaderMaterial; +/** #endregion 材质与着色 */ + +/** #region 纹理相关 */ +THREE.Texture = Texture; +THREE.VideoTexture = VideoTexture; +THREE.TextureLoader = TextureLoader; +/** #endregion 纹理相关 */ + +/** #region 物体与层级 */ +THREE.Object3D = Group; +THREE.Group = Group; +THREE.Mesh = Mesh; +THREE.PerspectiveCamera = PerspectiveCamera; +/** #endregion 物体与层级 */ + +// 导出THREE命名空间和工具函数 +exports.THREE = THREE; +exports.getCurrentScene = getCurrentScene; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..e66c48c1214e9291408c0279764dfea2a447c79c --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1,1455 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/** + * The Ease class provides a collection of easing functions for use with tween.js. + */ +var Easing = Object.freeze({ + Linear: Object.freeze({ + None: function (amount) { + return amount; + }, + In: function (amount) { + return amount; + }, + Out: function (amount) { + return amount; + }, + InOut: function (amount) { + return amount; + }, + }), + Quadratic: Object.freeze({ + In: function (amount) { + return amount * amount; + }, + Out: function (amount) { + return amount * (2 - amount); + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount; + } + return -0.5 * (--amount * (amount - 2) - 1); + }, + }), + Cubic: Object.freeze({ + In: function (amount) { + return amount * amount * amount; + }, + Out: function (amount) { + return --amount * amount * amount + 1; + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount * amount; + } + return 0.5 * ((amount -= 2) * amount * amount + 2); + }, + }), + Quartic: Object.freeze({ + In: function (amount) { + return amount * amount * amount * amount; + }, + Out: function (amount) { + return 1 - --amount * amount * amount * amount; + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount * amount * amount; + } + return -0.5 * ((amount -= 2) * amount * amount * amount - 2); + }, + }), + Quintic: Object.freeze({ + In: function (amount) { + return amount * amount * amount * amount * amount; + }, + Out: function (amount) { + return --amount * amount * amount * amount * amount + 1; + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount * amount * amount * amount; + } + return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); + }, + }), + Sinusoidal: Object.freeze({ + In: function (amount) { + return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2); + }, + Out: function (amount) { + return Math.sin((amount * Math.PI) / 2); + }, + InOut: function (amount) { + return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount))); + }, + }), + Exponential: Object.freeze({ + In: function (amount) { + return amount === 0 ? 0 : Math.pow(1024, amount - 1); + }, + Out: function (amount) { + return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount); + }, + InOut: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + if ((amount *= 2) < 1) { + return 0.5 * Math.pow(1024, amount - 1); + } + return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2); + }, + }), + Circular: Object.freeze({ + In: function (amount) { + return 1 - Math.sqrt(1 - amount * amount); + }, + Out: function (amount) { + return Math.sqrt(1 - --amount * amount); + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return -0.5 * (Math.sqrt(1 - amount * amount) - 1); + } + return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1); + }, + }), + Elastic: Object.freeze({ + In: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); + }, + Out: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1; + }, + InOut: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + amount *= 2; + if (amount < 1) { + return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); + } + return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1; + }, + }), + Back: Object.freeze({ + In: function (amount) { + var s = 1.70158; + return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s); + }, + Out: function (amount) { + var s = 1.70158; + return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1; + }, + InOut: function (amount) { + var s = 1.70158 * 1.525; + if ((amount *= 2) < 1) { + return 0.5 * (amount * amount * ((s + 1) * amount - s)); + } + return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2); + }, + }), + Bounce: Object.freeze({ + In: function (amount) { + return 1 - Easing.Bounce.Out(1 - amount); + }, + Out: function (amount) { + if (amount < 1 / 2.75) { + return 7.5625 * amount * amount; + } + else if (amount < 2 / 2.75) { + return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75; + } + else if (amount < 2.5 / 2.75) { + return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; + } + else { + return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; + } + }, + InOut: function (amount) { + if (amount < 0.5) { + return Easing.Bounce.In(amount * 2) * 0.5; + } + return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; + }, + }), + generatePow: function (power) { + if (power === void 0) { power = 4; } + power = power < Number.EPSILON ? Number.EPSILON : power; + power = power > 10000 ? 10000 : power; + return { + In: function (amount) { + return Math.pow(amount, power); + }, + Out: function (amount) { + return 1 - Math.pow((1 - amount), power); + }, + InOut: function (amount) { + if (amount < 0.5) { + return Math.pow((amount * 2), power) / 2; + } + return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5; + }, + }; + }, +}); + +var now = function () { + // 优先使用原生performance.now() + // if (typeof performance !== 'undefined' && performance.now) { + // return performance.now(); + // } + + // Node.js环境:使用高精度时间 + if (typeof process !== 'undefined' && process.hrtime) { + if (!now._nodeStartTime) { + now._nodeStartTime = process.hrtime(); + } + var hrTime = process.hrtime(now._nodeStartTime); + return hrTime[0] * 1000 + hrTime[1] / 1000000; + } + + // 浏览器兜底:模拟performance.now()行为 + if (typeof now._startTime === 'undefined') { + now._startTime = Date.now(); + now._lastReturned = 0; + } + + var elapsed = Date.now() - now._startTime; + + // 确保时间单调递增,同时添加微小递增来模拟高精度 + if (elapsed <= now._lastReturned) { + now._lastReturned += 0.001; + } else { + now._lastReturned = elapsed; + } + + return now._lastReturned; +}; +function setNow(nowFunction) { + _nowFunc = nowFunction; +} + +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tween + */ +var Group = /** @class */ (function () { + function Group() { + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + this._tweens = {}; + this._tweensAddedDuringUpdate = {}; + this.add.apply(this, tweens); + } + Group.prototype.getAll = function () { + var _this = this; + return Object.keys(this._tweens).map(function (tweenId) { return _this._tweens[tweenId]; }); + }; + Group.prototype.removeAll = function () { + this._tweens = {}; + }; + Group.prototype.add = function () { + var _a; + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) { + var tween = tweens_1[_b]; + // Remove from any other group first, a tween can only be in one group at a time. + // @ts-expect-error library internal access + (_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween); + // @ts-expect-error library internal access + tween._group = this; + this._tweens[tween.getId()] = tween; + this._tweensAddedDuringUpdate[tween.getId()] = tween; + } + }; + Group.prototype.remove = function () { + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) { + var tween = tweens_2[_a]; + // @ts-expect-error library internal access + tween._group = undefined; + delete this._tweens[tween.getId()]; + delete this._tweensAddedDuringUpdate[tween.getId()]; + } + }; + /** Return true if all tweens in the group are not paused or playing. */ + Group.prototype.allStopped = function () { + return this.getAll().every(function (tween) { return !tween.isPlaying(); }); + }; + Group.prototype.update = function (time, preserve) { + if (time === void 0) { time = now(); } + if (preserve === void 0) { preserve = true; } + var tweenIds = Object.keys(this._tweens); + if (tweenIds.length === 0) + return; + // Tweens are updated in "batches". If you add a new tween during an + // update, then the new tween will be updated in the next batch. + // If you remove a tween during an update, it may or may not be updated. + // However, if the removed tween was added during the current batch, + // then it will not be updated. + while (tweenIds.length > 0) { + this._tweensAddedDuringUpdate = {}; + for (var i = 0; i < tweenIds.length; i++) { + var tween = this._tweens[tweenIds[i]]; + var autoStart = !preserve; + if (tween && tween.update(time, autoStart) === false && !preserve) + this.remove(tween); + } + tweenIds = Object.keys(this._tweensAddedDuringUpdate); + } + }; + Group.prototype.onComplete = function (callback) { + var group = this.getAll(); + group.forEach(function (tween) { + var prevCallback = tween.getCompleteCallback(); + tween.onComplete(function () { + prevCallback === null || prevCallback === void 0 ? void 0 : prevCallback(tween); + // After the onComplete callback completes, _isPlaying is updated to false, so if the total number of completed tweens is -1, then they are all complete. + var completedGroup = group.filter(function (tween) { return !tween.isPlaying(); }); + if (completedGroup.length === group.length - 1) + callback(group); + }); + }); + }; + return Group; +}()); + +/** + * + */ +var Interpolation = { + Linear: function (v, k) { + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + var fn = Interpolation.Utils.Linear; + if (k < 0) { + return fn(v[0], v[1], f); + } + if (k > 1) { + return fn(v[m], v[m - 1], m - f); + } + return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); + }, + Bezier: function (v, k) { + var b = 0; + var n = v.length - 1; + var pw = Math.pow; + var bn = Interpolation.Utils.Bernstein; + for (var i = 0; i <= n; i++) { + b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); + } + return b; + }, + CatmullRom: function (v, k) { + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + var fn = Interpolation.Utils.CatmullRom; + if (v[0] === v[m]) { + if (k < 0) { + i = Math.floor((f = m * (1 + k))); + } + return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); + } + else { + if (k < 0) { + return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); + } + if (k > 1) { + return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); + } + return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); + } + }, + Utils: { + Linear: function (p0, p1, t) { + return (p1 - p0) * t + p0; + }, + Bernstein: function (n, i) { + var fc = Interpolation.Utils.Factorial; + return fc(n) / fc(i) / fc(n - i); + }, + Factorial: (function () { + var a = [1]; + return function (n) { + var s = 1; + if (a[n]) { + return a[n]; + } + for (var i = n; i > 1; i--) { + s *= i; + } + a[n] = s; + return s; + }; + })(), + CatmullRom: function (p0, p1, p2, p3, t) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; + }, + }, +}; + +/** + * Utils + */ +var Sequence = /** @class */ (function () { + function Sequence() { + } + Sequence.nextId = function () { + return Sequence._nextId++; + }; + Sequence._nextId = 0; + return Sequence; +}()); + +var mainGroup = new Group(); + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var Tween = /** @class */ (function () { + function Tween(object, group) { + this._isPaused = false; + this._pauseStart = 0; + this._valuesStart = {}; + this._valuesEnd = {}; + this._valuesStartRepeat = {}; + this._duration = 1000; + this._isDynamic = false; + this._initialRepeat = 0; + this._repeat = 0; + this._yoyo = false; + this._isPlaying = false; + this._reversed = false; + this._delayTime = 0; + this._startTime = 0; + this._easingFunction = Easing.Linear.None; + this._interpolationFunction = Interpolation.Linear; + // eslint-disable-next-line + this._chainedTweens = []; + this._onStartCallbackFired = false; + this._onEveryStartCallbackFired = false; + this._id = Sequence.nextId(); + this._isChainStopped = false; + this._propertiesAreSetUp = false; + this._goToEnd = false; + this._object = object; + if (typeof group === 'object') { + this._group = group; + group.add(this); + } + // Use "true" to restore old behavior (will be removed in future release). + else if (group === true) { + this._group = mainGroup; + mainGroup.add(this); + } + } + Tween.prototype.getId = function () { + return this._id; + }; + Tween.prototype.getCompleteCallback = function () { + return this._onCompleteCallback; + }; + Tween.prototype.isPlaying = function () { + return this._isPlaying; + }; + Tween.prototype.isPaused = function () { + return this._isPaused; + }; + Tween.prototype.getDuration = function () { + return this._duration; + }; + Tween.prototype.to = function (target, duration) { + if (duration === void 0) { duration = 1000; } + if (this._isPlaying) + throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.'); + this._valuesEnd = target; + this._propertiesAreSetUp = false; + this._duration = duration < 0 ? 0 : duration; + return this; + }; + Tween.prototype.duration = function (duration) { + if (duration === void 0) { duration = 1000; } + this._duration = duration < 0 ? 0 : duration; + return this; + }; + Tween.prototype.dynamic = function (dynamic) { + if (dynamic === void 0) { dynamic = false; } + this._isDynamic = dynamic; + return this; + }; + Tween.prototype.start = function (time, overrideStartingValues) { + if (time === void 0) { time = now(); } + if (overrideStartingValues === void 0) { overrideStartingValues = false; } + if (this._isPlaying) { + return this; + } + this._repeat = this._initialRepeat; + if (this._reversed) { + // If we were reversed (f.e. using the yoyo feature) then we need to + // flip the tween direction back to forward. + this._reversed = false; + for (var property in this._valuesStartRepeat) { + this._swapEndStartRepeatValues(property); + this._valuesStart[property] = this._valuesStartRepeat[property]; + } + } + this._isPlaying = true; + this._isPaused = false; + this._onStartCallbackFired = false; + this._onEveryStartCallbackFired = false; + this._isChainStopped = false; + this._startTime = time; + this._startTime += this._delayTime; + if (!this._propertiesAreSetUp || overrideStartingValues) { + this._propertiesAreSetUp = true; + // If dynamic is not enabled, clone the end values instead of using the passed-in end values. + if (!this._isDynamic) { + var tmp = {}; + for (var prop in this._valuesEnd) + tmp[prop] = this._valuesEnd[prop]; + this._valuesEnd = tmp; + } + this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues); + } + return this; + }; + Tween.prototype.startFromCurrentValues = function (time) { + return this.start(time, true); + }; + Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) { + for (var property in _valuesEnd) { + var startValue = _object[property]; + var startValueIsArray = Array.isArray(startValue); + var propType = startValueIsArray ? 'array' : typeof startValue; + var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]); + // If `to()` specifies a property that doesn't exist in the source object, + // we should not set that property in the object + if (propType === 'undefined' || propType === 'function') { + continue; + } + // Check if an Array was provided as property value + if (isInterpolationList) { + var endValues = _valuesEnd[property]; + if (endValues.length === 0) { + continue; + } + // Handle an array of relative values. + // Creates a local copy of the Array with the start value at the front + var temp = [startValue]; + for (var i = 0, l = endValues.length; i < l; i += 1) { + var value = this._handleRelativeValue(startValue, endValues[i]); + if (isNaN(value)) { + isInterpolationList = false; + console.warn('Found invalid interpolation list. Skipping.'); + break; + } + temp.push(value); + } + if (isInterpolationList) { + // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp. + _valuesEnd[property] = temp; + // } + } + } + // handle the deepness of the values + if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { + _valuesStart[property] = startValueIsArray ? [] : {}; + var nestedObject = startValue; + for (var prop in nestedObject) { + _valuesStart[property][prop] = nestedObject[prop]; + } + // TODO? repeat nested values? And yoyo? And array values? + _valuesStartRepeat[property] = startValueIsArray ? [] : {}; + var endValues = _valuesEnd[property]; + // If dynamic is not enabled, clone the end values instead of using the passed-in end values. + if (!this._isDynamic) { + var tmp = {}; + for (var prop in endValues) + tmp[prop] = endValues[prop]; + _valuesEnd[property] = endValues = tmp; + } + this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues); + } + else { + // Save the starting value, but only once unless override is requested. + if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) { + _valuesStart[property] = startValue; + } + if (!startValueIsArray) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings + } + if (isInterpolationList) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse(); + } + else { + _valuesStartRepeat[property] = _valuesStart[property] || 0; + } + } + } + }; + Tween.prototype.stop = function () { + if (!this._isChainStopped) { + this._isChainStopped = true; + this.stopChainedTweens(); + } + if (!this._isPlaying) { + return this; + } + this._isPlaying = false; + this._isPaused = false; + if (this._onStopCallback) { + this._onStopCallback(this._object); + } + return this; + }; + Tween.prototype.end = function () { + this._goToEnd = true; + this.update(this._startTime + this._duration); + return this; + }; + Tween.prototype.pause = function (time) { + if (time === void 0) { time = now(); } + if (this._isPaused || !this._isPlaying) { + return this; + } + this._isPaused = true; + this._pauseStart = time; + return this; + }; + Tween.prototype.resume = function (time) { + if (time === void 0) { time = now(); } + if (!this._isPaused || !this._isPlaying) { + return this; + } + this._isPaused = false; + this._startTime += time - this._pauseStart; + this._pauseStart = 0; + return this; + }; + Tween.prototype.stopChainedTweens = function () { + for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { + this._chainedTweens[i].stop(); + } + return this; + }; + Tween.prototype.group = function (group) { + if (!group) { + console.warn('tween.group() without args has been removed, use group.add(tween) instead.'); + return this; + } + group.add(this); + return this; + }; + /** + * Removes the tween from whichever group it is in. + */ + Tween.prototype.remove = function () { + var _a; + (_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this); + return this; + }; + Tween.prototype.delay = function (amount) { + if (amount === void 0) { amount = 0; } + this._delayTime = amount; + return this; + }; + Tween.prototype.repeat = function (times) { + if (times === void 0) { times = 0; } + this._initialRepeat = times; + this._repeat = times; + return this; + }; + Tween.prototype.repeatDelay = function (amount) { + this._repeatDelayTime = amount; + return this; + }; + Tween.prototype.yoyo = function (yoyo) { + if (yoyo === void 0) { yoyo = false; } + this._yoyo = yoyo; + return this; + }; + Tween.prototype.easing = function (easingFunction) { + if (easingFunction === void 0) { easingFunction = Easing.Linear.None; } + this._easingFunction = easingFunction; + return this; + }; + Tween.prototype.interpolation = function (interpolationFunction) { + if (interpolationFunction === void 0) { interpolationFunction = Interpolation.Linear; } + this._interpolationFunction = interpolationFunction; + return this; + }; + // eslint-disable-next-line + Tween.prototype.chain = function () { + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + this._chainedTweens = tweens; + return this; + }; + Tween.prototype.onStart = function (callback) { + this._onStartCallback = callback; + return this; + }; + Tween.prototype.onEveryStart = function (callback) { + this._onEveryStartCallback = callback; + return this; + }; + Tween.prototype.onUpdate = function (callback) { + this._onUpdateCallback = callback; + return this; + }; + Tween.prototype.onRepeat = function (callback) { + this._onRepeatCallback = callback; + return this; + }; + Tween.prototype.onComplete = function (callback) { + this._onCompleteCallback = callback; + return this; + }; + Tween.prototype.onStop = function (callback) { + this._onStopCallback = callback; + return this; + }; + /** + * @returns true if the tween is still playing after the update, false + * otherwise (calling update on a paused tween still returns true because + * it is still playing, just paused). + * + * @param autoStart - When true, calling update will implicitly call start() + * as well. Note, if you stop() or end() the tween, but are still calling + * update(), it will start again! + */ + Tween.prototype.update = function (time, autoStart) { + var _this = this; + var _a; + if (time === void 0) { time = now(); } + if (autoStart === void 0) { autoStart = Tween.autoStartOnUpdate; } + if (this._isPaused) + return true; + var property; + if (!this._goToEnd && !this._isPlaying) { + if (autoStart) + this.start(time, true); + else + return false; + } + this._goToEnd = false; + if (time < this._startTime) { + return true; + } + if (this._onStartCallbackFired === false) { + if (this._onStartCallback) { + this._onStartCallback(this._object); + } + this._onStartCallbackFired = true; + } + if (this._onEveryStartCallbackFired === false) { + if (this._onEveryStartCallback) { + this._onEveryStartCallback(this._object); + } + this._onEveryStartCallbackFired = true; + } + var elapsedTime = time - this._startTime; + var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime); + var totalTime = this._duration + this._repeat * durationAndDelay; + var calculateElapsedPortion = function () { + if (_this._duration === 0) + return 1; + if (elapsedTime > totalTime) { + return 1; + } + var timesRepeated = Math.trunc(elapsedTime / durationAndDelay); + var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay; + // TODO use %? + // const timeIntoCurrentRepeat = elapsedTime % durationAndDelay + var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1); + if (portion === 0 && elapsedTime === _this._duration) { + return 1; + } + return portion; + }; + var elapsed = calculateElapsedPortion(); + var value = this._easingFunction(elapsed); + // properties transformations + this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value); + if (this._onUpdateCallback) { + this._onUpdateCallback(this._object, elapsed); + } + if (this._duration === 0 || elapsedTime >= this._duration) { + if (this._repeat > 0) { + var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat); + if (isFinite(this._repeat)) { + this._repeat -= completeCount; + } + // Reassign starting values, restart by making startTime = now + for (property in this._valuesStartRepeat) { + if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { + this._valuesStartRepeat[property] = + // eslint-disable-next-line + // @ts-ignore FIXME? + this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); + } + if (this._yoyo) { + this._swapEndStartRepeatValues(property); + } + this._valuesStart[property] = this._valuesStartRepeat[property]; + } + if (this._yoyo) { + this._reversed = !this._reversed; + } + this._startTime += durationAndDelay * completeCount; + if (this._onRepeatCallback) { + this._onRepeatCallback(this._object); + } + this._onEveryStartCallbackFired = false; + return true; + } + else { + if (this._onCompleteCallback) { + this._onCompleteCallback(this._object); + } + for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { + // Make the chained tweens start exactly at the time they should, + // even if the `update()` method was called way past the duration of the tween + this._chainedTweens[i].start(this._startTime + this._duration, false); + } + this._isPlaying = false; + return false; + } + } + return true; + }; + Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) { + for (var property in _valuesEnd) { + // Don't update properties that do not exist in the source object + if (_valuesStart[property] === undefined) { + continue; + } + var start = _valuesStart[property] || 0; + var end = _valuesEnd[property]; + var startIsArray = Array.isArray(_object[property]); + var endIsArray = Array.isArray(end); + var isInterpolationList = !startIsArray && endIsArray; + if (isInterpolationList) { + _object[property] = this._interpolationFunction(end, value); + } + else if (typeof end === 'object' && end) { + // eslint-disable-next-line + // @ts-ignore FIXME? + this._updateProperties(_object[property], start, end, value); + } + else { + // Parses relative end values with start as base (e.g.: +10, -3) + end = this._handleRelativeValue(start, end); + // Protect against non numeric properties. + if (typeof end === 'number') { + // eslint-disable-next-line + // @ts-ignore FIXME? + _object[property] = start + (end - start) * value; + } + } + } + }; + Tween.prototype._handleRelativeValue = function (start, end) { + if (typeof end !== 'string') { + return end; + } + if (end.charAt(0) === '+' || end.charAt(0) === '-') { + return start + parseFloat(end); + } + return parseFloat(end); + }; + Tween.prototype._swapEndStartRepeatValues = function (property) { + var tmp = this._valuesStartRepeat[property]; + var endValue = this._valuesEnd[property]; + if (typeof endValue === 'string') { + this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue); + } + else { + this._valuesStartRepeat[property] = this._valuesEnd[property]; + } + this._valuesEnd[property] = tmp; + }; + Tween.autoStartOnUpdate = false; + return Tween; +}()); + +var VERSION = '25.0.0'; + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var nextId = Sequence.nextId; +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tweens. + */ +var TWEEN = mainGroup; +// This is the best way to export things in a way that's compatible with both ES +// Modules and CommonJS, without build hacks, and so as not to break the +// existing API. +// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881 +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var getAll = TWEEN.getAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var removeAll = TWEEN.removeAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var add = TWEEN.add.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var remove = TWEEN.remove.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var update = TWEEN.update.bind(TWEEN); +var exports$1 = { + Easing: Easing, + Group: Group, + Interpolation: Interpolation, + now: now, + setNow: setNow, + Sequence: Sequence, + nextId: nextId, + Tween: Tween, + VERSION: VERSION, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + getAll: getAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + removeAll: removeAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + add: add, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + remove: remove, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + update: update, +}; + +exports.Easing = Easing; +exports.Group = Group; +exports.Interpolation = Interpolation; +exports.Sequence = Sequence; +exports.Tween = Tween; +exports.VERSION = VERSION; +exports.add = add; +exports.default = exports$1; +exports.getAll = getAll; +exports.nextId = nextId; +exports.now = now; +exports.remove = remove; +exports.removeAll = removeAll; +exports.setNow = setNow; +exports.update = update; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Box2.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Box2.js new file mode 100644 index 0000000000000000000000000000000000000000..eb886973d02e86c0cb5201c6f1d953ce3c587e74 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Box2.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Box2{constructor(min,max){this.min=min!==undefined?min:new Vector2(Infinity,Infinity);this.max=max!==undefined?max:new Vector2(-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this}isEmpty(){return this.max.xthis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681214409993178375/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x) { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-6 * k) * Math.cos(12 * k); +}; + +// 欠阻尼弹簧(硬):更高频振荡、更慢收敛 +const springStiff = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(18 * k); +}; + +// 阻尼振荡:sin 基波收尾抖动 +const dampedOscillation = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(10 * k); +}; + +const Physics = Object.freeze({ + SpringSoft: springSoft, + SpringStiff: springStiff, + DampedOscillation: dampedOscillation, +}); + +// ─── §4 Motion 动作设计系 ────────────────────────────────────────────────── + +// 先回拉 10% 再冲向终点:蓄力动作 +const anticipate = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const pullback = 0.1; + if (k < 0.3) { + const p = k / 0.3; + return -pullback * p * (2 - p); // easeOutQuad 到 -pullback + } + const p = (k - 0.3) / 0.7; + return -pullback + (1 + pullback) * p * p * (3 - 2 * p); // smoothstep 到 1 +}; + +// 冲到 peak 再回到 1 的工厂 +const overshootFactory = (peak) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return peak * p * (2 - p); // easeOutQuad 到 peak + } + const p = (k - 0.6) / 0.4; + return peak + (1 - peak) * (1 - Math.pow(1 - p, 3)); // easeOutCubic 到 1 +}; + +const overshoot110 = overshootFactory(1.10); +const overshoot125 = overshootFactory(1.25); + +// 快速到位(前 60% 冲到 1.05),后 40% 回到 1:磁吸、卡扣 +const snapBack = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return 1.05 * (1 - Math.pow(1 - p, 3)); + } + const p = (k - 0.6) / 0.4; + return 1.05 - 0.05 * p * p * (3 - 2 * p); +}; + +// 摆锤式:一次轻微过冲后收敛 +const swing = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.cos(1.5 * Math.PI * k) * Math.exp(-2.5 * k); +}; + +const Motion = Object.freeze({ + Anticipate: anticipate, + Overshoot110: overshoot110, + Overshoot125: overshoot125, + SnapBack: snapBack, + Swing: swing, +}); + +// ─── §5 Step 步进系 ──────────────────────────────────────────────────────── + +/** + * CSS steps() 等价工厂。 + * @param {number} n 段数 + * @param {'start' | 'end'} jumpTerm 跳变在每段的起始还是结束(默认 'end') + */ +const makeStep = (n, jumpTerm = 'end') => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (jumpTerm === 'start') return Math.ceil(k * n) / n; + return Math.floor(k * n) / n; +}; + +const Step = Object.freeze({ + Steps4End: makeStep(4, 'end'), + Steps8End: makeStep(8, 'end'), + Steps12End: makeStep(12, 'end'), +}); + +// ─── §6 Bezier 规范贝塞尔 ────────────────────────────────────────────────── + +/** + * 给定两个控制点 (x1,y1) 与 (x2,y2),P0=(0,0) P3=(1,1)。 + * 返回函数 f(t) -> y,其中 t 是输入时间(需先用牛顿法从 x 反解 s)。 + */ +function buildCubicBezier(x1, y1, x2, y2) { + const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx; + const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by; + const sampleX = (s) => ((ax * s + bx) * s + cx) * s; + const sampleY = (s) => ((ay * s + by) * s + cy) * s; + const sampleDX = (s) => (3 * ax * s + 2 * bx) * s + cx; + + const solveS = (x) => { + let s = x; + for (let i = 0; i < 8; i++) { + const cur = sampleX(s) - x; + if (Math.abs(cur) < 1e-6) return s; + const d = sampleDX(s); + if (Math.abs(d) < 1e-6) break; + s -= cur / d; + if (s < 0) s = 0; + if (s > 1) s = 1; + } + // 兜底二分 + let lo = 0, hi = 1; + for (let i = 0; i < 32 && hi - lo > 1e-6; i++) { + const mid = (lo + hi) / 2; + if (sampleX(mid) < x) lo = mid; else hi = mid; + } + return (lo + hi) / 2; + }; + + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return sampleY(solveS(k)); + }; +} + +// 贝塞尔白名单:(x1, y1, x2, y2) +const BEZIER_PRESETS = Object.freeze({ + 'Material.Standard': [0.4, 0, 0.2, 1], + 'Material.Accelerate': [0.4, 0, 1, 1], + 'Material.Decelerate': [0, 0, 0.2, 1], + 'CSS.Ease': [0.25, 0.1, 0.25, 1], +}); + +// 工厂 memoization(避免同参数重复构造) +const _bezierCache = new Map(); +function _cachedBezier(x1, y1, x2, y2) { + const key = x1 + ',' + y1 + ',' + x2 + ',' + y2; + let fn = _bezierCache.get(key); + if (!fn) { + fn = buildCubicBezier(x1, y1, x2, y2); + _bezierCache.set(key, fn); + } + return fn; +} + +/** + * cubicBezier('Material.Standard') | cubicBezier(x1, y1, x2, y2) + * 直写参数受控域:x1/x2 ∈ [0,1],y1/y2 ∈ [-0.5, 1.5] + */ +function cubicBezier(a, b, c, d) { + if (typeof a === 'string') { + let preset = BEZIER_PRESETS[a]; + if (!preset) { + console.warn('[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:', a); + preset = BEZIER_PRESETS['Material.Standard']; + } + return _cachedBezier(preset[0], preset[1], preset[2], preset[3]); + } + // 数值入口:裁剪到允许域 + const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v)); + const x1 = clamp(a, 0, 1); + const y1 = clamp(b, -0.5, 1.5); + const x2 = clamp(c, 0, 1); + const y2 = clamp(d, -0.5, 1.5); + return _cachedBezier(x1, y1, x2, y2); +} + +// 命名贝塞尔实例已整组移除:Material/CSS 预设与原生 Sinusoidal/Quadratic/Cubic +// 数值上几乎等价,特殊场景请直接调用 cubicBezier('Material.Standard') 等工厂。 + +// ═══════════════════════════════════════════════════════════════════════════ +// 扩展分组(与已有 6 组并列,不污染既有命名空间) +// ═══════════════════════════════════════════════════════════════════════════ + +// ─── §7 业界库扩展(已并入 Physics / Step / Heart) ───────────────────────── +// 以下工厂原本聚合在 Lib.* 命名空间下,现已按语义归入相应主题: +// Spring (Framer Motion) → Progress.Physics.Spring +// Steps (GSAP) → Progress.Step.Steps6 +// HeartBeat → Wave.Heart.Beat +// 退役:Framer Motion 的 Anticipate / GSAP 的 Overshoot factory(由 Motion.* +// 覆盖);GSAP ExpoScale / Unity SmoothDamp(数值上与原生 Sinusoidal/Quadratic +// 等价,已整组移除)。 + +// Spring(Framer Motion 风格):参数化弹簧,离散积分 +const libSpring = ({ stiffness = 180, damping = 12, mass = 1 } = {}) => { + const DT = 1 / 240; + const T = 1.5; + let x = 0, v = 0; + const samples = []; + for (let t = 0; t <= T; t += DT) { + const force = -stiffness * (x - 1) - damping * v; + v += (force / mass) * DT; + x += v * DT; + samples.push({ t, x }); + } + let T_end = T; + for (let i = samples.length - 1; i >= 0; i--) { + if (Math.abs(samples[i].x - 1) > 0.01) { T_end = samples[i].t; break; } + } + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const t = k * T_end; + const idx = Math.min(samples.length - 1, Math.floor(t / DT)); + return samples[idx].x; + }; +}; + +// HeartBeat(简易版):两高斯峰的绝对值轨迹 +const libHeartBeat = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c) => Math.exp(-((t - c) ** 2) / (2 * 0.07 * 0.07)); + return peak * (bell(k, 0.2) + bell(k, 0.5)); +}; + +// Steps(GSAP SteppedEase 风格 factory):离散 N 段阶梯(默认 n=6) +const libSteps = (n = 6) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return Math.floor(k * n) / n; +}; + +// ─── §8 Attention 注意力 / 抖振 ──────────────────────────────────────────── + +// Ping:单次衰减脉冲(雷达 ping),sin(π·k) × exp(-decay·k) +const attentionPing = (peak = 0.35, decay = 2) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(Math.PI * k) * Math.exp(-decay * k); +}; + +// Wiggle:衰减正弦振荡(easing 值本身,非位置增量) +const attentionWiggle = (count = 4, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + return amplitude * env * Math.sin(k * Math.PI * 2 * count); +}; + +// Strum:多峰衰减(吉他拨弦) +const attentionStrum = (notes = 4, peak = 0.4) => { + const centers = []; + for (let i = 0; i < notes; i++) { + centers.push({ c: 0.15 + i * (0.7 / Math.max(1, notes - 1)), a: Math.pow(0.72, i) }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * 0.05 * 0.05)); + } + return peak * sum; + }; +}; + +const Attention = Object.freeze({ + Ping: attentionPing(), + Wiggle: attentionWiggle(), + Strum: attentionStrum(), +}); + +// ─── §9 Breath 呼吸 ──────────────────────────────────────────────────────── + +// Normal:慢节奏正弦呼吸 +const breathNormal = (cycles = 2, peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(k * Math.PI * 2 * cycles) * Math.sin(k * Math.PI); +}; + +// Deep:深呼吸——慢吸气 → hold → 慢呼气 +const breathDeep = (peak = 0.3, riseRatio = 0.35, holdRatio = 0.15) => { + const holdEnd = riseRatio + holdRatio; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + if (k < holdEnd) { + return peak; + } + const t = (k - holdEnd) / (1 - holdEnd); + return peak * Math.cos(t * Math.PI / 2); + }; +}; + +// Panting:急促浅呼吸——多次小幅起伏 + 正弦包络 +const breathPanting = (cycles = 6, peak = 0.08) => (k) => { + if (k <= 0 || k >= 1) return 0; + const envelope = Math.sin(k * Math.PI); + const wave = 0.5 + 0.5 * Math.sin(k * Math.PI * 2 * cycles - Math.PI / 2); + return peak * envelope * wave; +}; + +// Sigh:叹息——快速吸气后慢速释放 +const breathSigh = (peak = 0.25, riseRatio = 0.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + const t = (k - riseRatio) / (1 - riseRatio); + return peak * (1 - t) * (1 - t); +}; + +const Breath = Object.freeze({ + Normal: breathNormal(), + Deep: breathDeep(), + Panting: breathPanting(), + Sigh: breathSigh(), +}); + +// ─── §10 Heart 心跳 ──────────────────────────────────────────────────────── + +// Calm:单次舒缓心跳——单高斯峰 +const heartCalm = (peak = 0.25, center = 0.35, width = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.exp(-((k - center) ** 2) / (2 * width * width)); +}; + +// Excited:兴奋/紧张——密集快速心跳(N 连击) +const heartExcited = (beats = 4, peak = 0.3, width = 0.04) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < beats; i++) { + centers.push(0.15 + i * (span / Math.max(1, beats - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * width * width)); + } + return peak * sum; + }; +}; + +// LubDub:标准心跳「lub-dub」双音节 +const heartLubDub = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + // lub(S1):中心 0.25、宽 0.045、幅 1.0 + // dub(S2):中心 0.42、宽 0.03、幅 0.6 + return peak * (bell(k, 0.25, 0.045) + 0.6 * bell(k, 0.42, 0.03)); +}; + +const Heart = Object.freeze({ + Calm: heartCalm(), + Excited: heartExcited(), + LubDub: heartLubDub(), +}); + +// ─── §11 Math 物理 / 数学 ───────────────────────────────────────────────── + +// JumpArc:抛物线轨迹 4k(1-k) +const mathJumpArc = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 4 * k * (1 - k); +}; + +// Pendulum:物理摆——sin(πk) 包络的衰减余弦,端点归零(满足 Wave 契约 f(0)=f(1)=0) +const mathPendulum = (damping = 3, freq = 2.5) => (k) => { + if (k <= 0 || k >= 1) return 0; + return Math.sin(k * Math.PI) * Math.exp(-damping * k) * Math.cos(freq * Math.PI * k); +}; + +// Tremor:持续高频小幅抖动(不衰减),整体沿 Linear 进行 +const mathTremor = (amplitude = 0.04, freq = 22) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return k + amplitude * Math.sin(k * Math.PI * 2 * freq); +}; + +// Boomerang 包装器:把任意 easing 包装成 0→1→0(先去再回)。 +// 仅作为内部辅助使用,不暴露为公共曲线——常用变体已预实例化为 +// Pulse.Math.BoomerangSharp / BoomerangSoft(见 Pulse 命名空间)。 +const mathBoomerang = (fn) => (k) => { + if (k <= 0 || k >= 1) return 0; + return k < 0.5 ? fn(k * 2) : fn(2 - k * 2); +}; + +const MathExt = Object.freeze({ + JumpArc: mathJumpArc(), + Pendulum: mathPendulum(), + Tremor: mathTremor(), +}); + +// ─── §12 Explosion 爆炸 ──────────────────────────────────────────────────── + +// Impulse:指数脉冲响应 k·e^(1-k·sharpness)(减线性尾项使 k=1 归 0) +const explosionImpulse = (sharpness = 6) => { + const tail = sharpness * Math.exp(1 - sharpness); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const h = sharpness * k; + return h * Math.exp(1 - h) - tail * k; + }; +}; + +// Flash:瞬间拉满 + 指数衰减到 0 +const explosionFlash = (rise = 0.05, decay = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < rise) return k / rise; + return Math.exp(-decay * (k - rise)); +}; + +// Recoil:爆炸反冲——负向冲击 -1 + 阻尼振荡 +const explosionRecoil = (decay = 4, freq = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + return -Math.exp(-decay * k) * Math.cos(freq * Math.PI * k); +}; + +// Implosion:三段式——负向吸能 → 正向爆发 → 衰减归 0 +const explosionImplosion = (charge = 0.3, depth = 0.4, burstPeak = 1.2) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < charge) { + const t = k / charge; + return -depth * Math.sin(t * Math.PI / 2); + } + const t = (k - charge) / (1 - charge); + const h = sharp * t; + const wave = h * Math.exp(1 - h) - tail * t; + const settle = -depth * Math.pow(1 - t, 3); + return settle + burstPeak * wave; + }; +}; + +const Explosion = Object.freeze({ + Impulse: explosionImpulse(), + Flash: explosionFlash(), + Recoil: explosionRecoil(), + Implosion: explosionImplosion(), +}); + +// ─── §13 Cinema(已整组移除:Creep=k^3.5 与 Cubic.In/Quartic.In 数值等价) ─ + +// ─── §14 Nature 自然现象 ─────────────────────────────────────────────────── + +// Wave:海浪律动——多谐波叠加 + 整体正弦包络 +const natureWave = (cycles = 3, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const w = Math.sin(k * Math.PI * 2 * cycles) + + 0.5 * Math.sin(k * Math.PI * 2 * cycles * 1.5 + 1.2) + + 0.25 * Math.sin(k * Math.PI * 2 * cycles * 3 + 2.4); + return amplitude * env * w * 0.6; +}; + +// Flicker:火焰闪烁——伪随机采样 + 线性插值 + 正弦包络 +const natureFlicker = (rate = 15, intensity = 0.2, seed = 7) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= rate + 1; i++) samples.push(rand()); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * rate; + const idx = Math.floor(pos); + const t = pos - idx; + const a = samples[idx]; + const b = samples[idx + 1]; + const interp = a + (b - a) * t; + return intensity * env * (interp - 0.5) * 2; + }; +}; + +// Gust:风——N 次高斯阵风叠加 +const natureGust = (gusts = 3, peak = 0.25) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < gusts; i++) { + centers.push(0.15 + i * (span / Math.max(1, gusts - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * 0.08 * 0.08)); + } + return peak * sum / gusts * 1.8; + }; +}; + +const Nature = Object.freeze({ + Wave: natureWave(), + Flicker: natureFlicker(), + Gust: natureGust(), +}); + +// ─── §15 Impact 撞击 / 落地 ──────────────────────────────────────────────── + +// Rain:雨滴下落——重力加速段 + 撞击 + 小幅余震 +const impactRain = (impactAt = 0.7, rippleAmp = 0.08) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + return 1 + rippleAmp * Math.exp(-4 * t) * Math.sin(t * Math.PI * 6); +}; + +// Hammer:锤击——抬起蓄力(负值)→ 快速下击 → 微反弹 +const impactHammer = (liftDepth = 0.25) => { + const liftEnd = 0.35, strikeEnd = 0.6; + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < liftEnd) { + const t = k / liftEnd; + return -liftDepth * Math.sin(t * Math.PI); + } + if (k < strikeEnd) { + const t = (k - liftEnd) / (strikeEnd - liftEnd); + return t * t; + } + const t = (k - strikeEnd) / (1 - strikeEnd); + return 1 - 0.06 * Math.exp(-5 * t) * Math.sin(t * Math.PI * 4); + }; +}; + +// BounceDrop:下落 + 多次衰减反弹 +const impactBounceDrop = (bounces = 3, rebound = 0.25) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return t * t; + } + const t = (k - 0.4) / 0.6; + const env = Math.exp(-2.5 * t); + const wave = Math.abs(Math.sin(t * Math.PI * bounces)); + return 1 - env * wave * rebound; +}; + +// Slap:拍击——快速接触 + 短暂保持 + 快速撤回 +const impactSlap = (contactAt = 0.3, holdRatio = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < contactAt) { + const t = k / contactAt; + return t * t; + } + if (k < contactAt + holdRatio) return 1; + const t = (k - contactAt - holdRatio) / (1 - contactAt - holdRatio); + return (1 - t) * (1 - t); +}; + +// ArrowHit:箭中靶——匀速飞行 + 命中 + 插入后高频振颤衰减 +const impactArrowHit = (impactAt = 0.5) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * (0.7 + 0.3 * t); + } + const t = (k - impactAt) / (1 - impactAt); + const env = Math.exp(-5 * t); + const wave = Math.sin(t * Math.PI * 10); + return 1 + 0.1 * env * wave; +}; + +// Shatter:撞碎——下落 + 撞击 + 能量 impulse 爆发 + 回到 1 +const impactShatter = (impactAt = 0.55, burstAmp = 0.35) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + const h = sharp * t; + const impulseVal = h * Math.exp(1 - h) - tail * t; + return 1 + burstAmp * impulseVal; + }; +}; + +const Impact = Object.freeze({ + Rain: impactRain(), + Hammer: impactHammer(), + BounceDrop: impactBounceDrop(), + Slap: impactSlap(), + ArrowHit: impactArrowHit(), + Shatter: impactShatter(), +}); + +// ─── §16 Rhythm 节奏 / 冲击 ──────────────────────────────────────────────── + +// BassDrop:EDM 重拍——缓慢蓄力 → pause pre-drop → 瞬间掉到 1 → 持续并有微脉动 +const rhythmBassDrop = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return 0.4 * Math.pow(t, 2.5); + } + if (k < 0.48) { + const t = (k - 0.4) / 0.08; + return 0.4 - 0.2 * t; + } + if (k < 0.52) { + const t = (k - 0.48) / 0.04; + return 0.2 + 0.8 * t; + } + const t = (k - 0.52) / 0.48; + return 1 - 0.04 * Math.sin(t * Math.PI * 8) * (1 - t); +}; + +// PunchCombo:拳击三连击——jab-jab-cross,第三拳最重最宽 +const rhythmPunchCombo = (peak = 0.4) => { + const pattern = [ + { c: 0.15, w: 0.04, a: 0.75 }, + { c: 0.35, w: 0.04, a: 0.75 }, + { c: 0.7, w: 0.055, a: 1.0 }, + ]; + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of pattern) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return peak * sum; + }; +}; + +// Staccato:断奏——均匀节拍内 duty 占空比 sin 脉冲 +const rhythmStaccato = (beats = 4, duty = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const beatLen = 1 / beats; + const phase = (k / beatLen) - Math.floor(k / beatLen); + if (phase > duty) return 0; + const t = phase / duty; + return Math.sin(t * Math.PI); +}; + +// Kick:极限单击——瞬速冲到 peak,之后强指数衰减 +const rhythmKick = (peak = 1.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.05) return peak * k / 0.05; + const t = (k - 0.05) / 0.95; + return peak * Math.exp(-4 * t); +}; + +// Crescendo:渐强——N 次高斯峰,间距递减、幅度递增 +const rhythmCrescendo = (beats = 4) => { + const centers = []; + for (let i = 0; i < beats; i++) { + const t = Math.pow((i + 1) / beats, 1.4); + centers.push({ c: Math.max(0.05, t - 0.08), w: 0.03, a: (i + 1) / beats }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return sum; + }; +}; + +// DunDunDun:悬疑递进——3 击幅度递增,末击更宽形成持续感 +const rhythmDunDunDun = () => { + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + return (k) => { + if (k <= 0 || k >= 1) return 0; + return 0.3 * bell(k, 0.15, 0.025) + + 0.6 * bell(k, 0.35, 0.03) + + 1.0 * bell(k, 0.68, 0.09); + }; +}; + +// BellToll:钟声——瞬间起振 + 指数衰减调幅的余弦振荡 +const rhythmBellToll = (decay = 3, freq = 8) => { + const strike = 0.05; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < strike) return k / strike; + const t = k - strike; + return Math.exp(-decay * t) * Math.cos(freq * Math.PI * t); + }; +}; + +const Rhythm = Object.freeze({ + BassDrop: rhythmBassDrop(), + PunchCombo: rhythmPunchCombo(), + Staccato: rhythmStaccato(), + Kick: rhythmKick(), + Crescendo: rhythmCrescendo(), + DunDunDun: rhythmDunDunDun(), + BellToll: rhythmBellToll(), +}); + +// ─── §17 UI 反馈 ─────────────────────────────────────────────────────────── + +// ClickSnap:按钮点击——压下(负偏移)→ 回弹微过冲 → 归零 +const uiClickSnap = (pressDepth = 0.3, reboundPeak = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.2) { + const t = k / 0.2; + return -pressDepth * Math.sin(t * Math.PI / 2); + } + if (k < 0.5) { + const t = (k - 0.2) / 0.3; + return -pressDepth + (pressDepth + reboundPeak) * (1 - Math.pow(1 - t, 3)); + } + const t = (k - 0.5) / 0.5; + return reboundPeak * Math.exp(-4 * t) * Math.cos(t * Math.PI * 3); +}; + +// HoverBloom:悬停高亮——梯形包络(快升 → plateau → 快降) +const uiHoverBloom = (riseRatio = 0.2, fallRatio = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return 1 - Math.pow(1 - t, 3); + } + if (k < 1 - fallRatio) return 1; + const t = (k - (1 - fallRatio)) / fallRatio; + return Math.pow(1 - t, 3); +}; + +// ErrorShake:错误反馈——方波化高频 shake +const uiErrorShake = (amplitude = 0.15, count = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + const raw = Math.sin(k * Math.PI * 2 * count); + const clipped = Math.sign(raw) * Math.min(1, Math.abs(raw) * 1.8); + return amplitude * env * clipped; +}; + +// SuccessPop:成功庆祝——瞬速 scale 到 1.2 → 阻尼余弦回到 1 +const uiSuccessPop = (overshoot = 0.2) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return (1 + overshoot) * (1 - Math.pow(1 - t, 2)); + } + const t = (k - 0.4) / 0.6; + return 1 + overshoot * Math.exp(-5 * t) * Math.cos(t * Math.PI * 3); +}; + +// RippleOut:Material 点击涟漪——早峰后淡出 +const uiRippleOut = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 6.75 * k * Math.pow(1 - k, 2); +}; + +const UI = Object.freeze({ + ClickSnap: uiClickSnap(), + HoverBloom: uiHoverBloom(), + ErrorShake: uiErrorShake(), + SuccessPop: uiSuccessPop(), + RippleOut: uiRippleOut(), +}); + +// ─── §18 Magic 能量 / 魔法 ───────────────────────────────────────────────── + +// ManaCharge:魔法蓄能——指数积蓄 + 高频 pulses +const magicManaCharge = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const base = (Math.exp(3 * k) - 1) / (Math.exp(3) - 1); + const pulse = 0.04 * Math.sin(k * Math.PI * 8) * k; + return base + pulse; +}; + +// SpellCast:施法——蓄能 + 瞬冲 1 + 拖尾衰减 +const magicSpellCast = (chargeEnd = 0.4) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < chargeEnd) { + const t = k / chargeEnd; + return 0.3 * Math.pow(t, 2) * (1 + 0.2 * Math.sin(t * Math.PI * 6)); + } + if (k < chargeEnd + 0.1) { + const t = (k - chargeEnd) / 0.1; + return 0.3 + 0.7 * t; + } + const t = (k - chargeEnd - 0.1) / (1 - chargeEnd - 0.1); + return Math.exp(-2 * t) * (1 + 0.1 * Math.cos(t * Math.PI * 4)); +}; + +// Teleport:瞬移——加速压缩 → 完全消失(平顶 1)→ 加速重现 +const magicTeleport = () => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.45) { + const t = k / 0.45; + return t * t * t; + } + if (k < 0.55) return 1; + const t = (k - 0.55) / 0.45; + return Math.pow(1 - t, 3); +}; + +// Shield:护盾——波纹扩散过冲到 1.2 → 稳定到 1 → 微脉动 +const magicShield = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.3) { + const t = k / 0.3; + return 1.2 * (1 - Math.pow(1 - t, 2)); + } + if (k < 0.6) { + const t = (k - 0.3) / 0.3; + return 1.2 - 0.2 * t; + } + const t = (k - 0.6) / 0.4; + return 1 + 0.03 * Math.sin(t * Math.PI * 3); +}; + +// MagicAura:魔法光环——基频 + 2 次谐波 + 3 次泛音的正弦叠加 +const magicAura = (peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const fundamental = 0.6 * Math.sin(k * Math.PI * 2); + const harmonic = 0.3 * Math.sin(k * Math.PI * 4 + 1); + const overtone = 0.1 * Math.sin(k * Math.PI * 6 + 2); + return peak * env * (fundamental + harmonic + overtone); +}; + +const Magic = Object.freeze({ + ManaCharge: magicManaCharge(), + SpellCast: magicSpellCast(), + Teleport: magicTeleport(), + Shield: magicShield(), + MagicAura: magicAura(), +}); + +// ─── §19 Animal 动物动作 ─────────────────────────────────────────────────── + +// CatPounce:猫扑击——蹲伏蓄力 + 起跳 + 空中抛物线 + 落地微压 +const animalCatPounce = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.2) { + const t = k / 0.2; + return -0.2 * Math.sin(t * Math.PI); + } + if (k < 0.3) { + const t = (k - 0.2) / 0.1; + return 0.5 * t * t; + } + if (k < 0.8) { + const t = (k - 0.3) / 0.5; + return 0.5 + 0.5 * t + 0.2 * Math.sin(t * Math.PI); + } + const t = (k - 0.8) / 0.2; + return 1 + 0.05 * Math.sin(t * Math.PI); +}; + +// BirdFlap:翅膀拍打——不对称基波(下扑快、上挥慢)+ sin 包络 +const animalBirdFlap = (flaps = 4) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const phase = k * Math.PI * 2 * flaps; + const wave = Math.sin(phase) - 0.3 * Math.sin(phase * 2); + return 0.2 * env * wave; +}; + +// SnakeSlither:蛇蜿蜒——连续 S 波 +const animalSnakeSlither = (waves = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const wave = Math.sin(k * Math.PI * 2 * waves); + return 0.2 * env * wave; +}; + +// ButterflyFlit:蝴蝶乱飞——seed 可复现的随机采样 + cubic 平滑插值 +const animalButterflyFlit = (seed = 13) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= 26; i++) samples.push(rand() - 0.5); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * 25; + const idx = Math.floor(pos); + const t = pos - idx; + const smooth = t * t * (3 - 2 * t); + const interp = samples[idx] + (samples[idx + 1] - samples[idx]) * smooth; + return 0.3 * env * interp; + }; +}; + +// HorseGallop:马奔驰——每周期 4 蹄击地 + 空中相位间隙 +const animalHorseGallop = (cycles = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const cyclePos = (k * cycles) - Math.floor(k * cycles); + const bell = (c, w = 0.04) => Math.exp(-((cyclePos - c) ** 2) / (2 * w * w)); + return 0.25 * env * (bell(0.0) + bell(0.18) + bell(0.36) + bell(0.54)); +}; + +const Animal = Object.freeze({ + CatPounce: animalCatPounce(), + BirdFlap: animalBirdFlap(), + SnakeSlither: animalSnakeSlither(), + ButterflyFlit: animalButterflyFlit(), + HorseGallop: animalHorseGallop(), +}); + +// ─── 导出(形态分类:Progress / Pulse / Wave) ───────────────────────────── +// +// 上方各主题常量(Physics / Motion / Step / Attention / Breath / Heart / +// MathExt / Explosion / Nature / Impact / Rhythm / UI / Magic / Animal) +// 及业界库 factory(libSpring / libSteps / libHeartBeat)仅作为 +// "源池"使用,不再作为顶层导出;由下列 Progress / Pulse / Wave 三个按形态 +// 分类的命名空间统一暴露。 +// +// 通用 UI 柔化(Smooth / Bezier 两组共 6 条命名曲线)已整组移除——数值上 +// 与原生 Sinusoidal/Quadratic/Cubic 等价;需定制贝塞尔请直接调用顶层 +// cubicBezier('Material.Standard' | x1,y1,x2,y2) 工厂。 + +// Progress —— 单调或衰减至 1 的曲线(A→B 过渡) +const Progress = Object.freeze({ + // Physics:原生 + Spring(Framer Motion 参数化弹簧) + Physics: Object.freeze({ + ...Physics, // SpringSoft / SpringStiff / DampedOscillation + Spring: libSpring(), // Framer Motion 风格默认弹簧 + }), + Motion, // Anticipate / Overshoot110 / Overshoot125 / SnapBack / Swing + // Step:固定段数实例 —— Steps4/6/8/12End 覆盖实用区间,无任意段数工厂 + Step: Object.freeze({ + ...Step, // Steps4End / Steps8End / Steps12End + Steps6: libSteps(), + }), + Math: Object.freeze({ + Tremor: MathExt.Tremor, + }), + Impact: Object.freeze({ + Rain: Impact.Rain, + Hammer: Impact.Hammer, + BounceDrop: Impact.BounceDrop, + ArrowHit: Impact.ArrowHit, + Shatter: Impact.Shatter, + }), + Rhythm: Object.freeze({ + BassDrop: Rhythm.BassDrop, + }), + UI: Object.freeze({ + SuccessPop: UI.SuccessPop, + }), + Magic: Object.freeze({ + ManaCharge: Magic.ManaCharge, + Shield: Magic.Shield, + }), + Animal: Object.freeze({ + CatPounce: Animal.CatPounce, + }), +}); + +// Pulse —— 单次返零脉冲(f(0)=f(1)=0, 单主峰;reversals ≤ 2 为主) +const Pulse = Object.freeze({ + Attention: Object.freeze({ + Ping: Attention.Ping, + }), + Breath: Object.freeze({ + Deep: Breath.Deep, + Sigh: Breath.Sigh, + }), + Heart: Object.freeze({ + Calm: Heart.Calm, + }), + Math: Object.freeze({ + JumpArc: MathExt.JumpArc, // 对称抛物 4k(1-k) + BoomerangSharp: mathBoomerang(E.Cubic.In), // 尖峰回程:缓→冲到峰→缓回(峰值锐利) + BoomerangSoft: mathBoomerang(E.Cubic.Out), // 平顶回程:快→在峰上停留→快回(峰值平滑) + }), + Explosion: Object.freeze({ + Impulse: Explosion.Impulse, + Flash: Explosion.Flash, + Recoil: Explosion.Recoil, + Implosion: Explosion.Implosion, + }), + Impact: Object.freeze({ + Slap: Impact.Slap, + }), + Rhythm: Object.freeze({ + Kick: Rhythm.Kick, + }), + UI: Object.freeze({ + ClickSnap: UI.ClickSnap, + HoverBloom: UI.HoverBloom, + RippleOut: UI.RippleOut, + }), + Magic: Object.freeze({ + SpellCast: Magic.SpellCast, + Teleport: Magic.Teleport, + }), +}); + +// Wave —— 周期多峰振荡(f(0)=f(1)=0, 多次反转) +const Wave = Object.freeze({ + Attention: Object.freeze({ + Wiggle: Attention.Wiggle, + Strum: Attention.Strum, + }), + Breath: Object.freeze({ + Normal: Breath.Normal, + Panting: Breath.Panting, + }), + Heart: Object.freeze({ + Excited: Heart.Excited, + LubDub: Heart.LubDub, + Beat: libHeartBeat(), // 迁移自 Lib.HeartBeat + }), + Math: Object.freeze({ + Pendulum: MathExt.Pendulum, + }), + Nature, // Wave / Flicker / Gust + Rhythm: Object.freeze({ + PunchCombo: Rhythm.PunchCombo, + Staccato: Rhythm.Staccato, + Crescendo: Rhythm.Crescendo, + DunDunDun: Rhythm.DunDunDun, + BellToll: Rhythm.BellToll, + }), + UI: Object.freeze({ + ErrorShake: UI.ErrorShake, + }), + Magic: Object.freeze({ + MagicAura: Magic.MagicAura, + }), + Animal: Object.freeze({ + BirdFlap: Animal.BirdFlap, + SnakeSlither: Animal.SnakeSlither, + ButterflyFlit: Animal.ButterflyFlit, + HorseGallop: Animal.HorseGallop, + }), +}); + +const customEasings = Object.freeze({ + makeOutIn, + OutIn, + Progress, + Pulse, + Wave, + cubicBezier, +}); + +exports.customEasings = customEasings; +exports.default = customEasings; diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..8642c5b96e62ccd27ab63ba9d26170c4e3bf2d07 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,800 @@ +/** + * 场景核心模块 + * + * 包含Three.js核心对象的创建和管理 + * 提供场景管理的核心功能:初始化、配置和更新 + */ + +// ThreeJS Env +// 导入TWEEN库 +// const TWEEN = require('../lib/tween'); +// 导入Three.js库 +// const THREE = require('three'); + + +// Effect Env +// 导入TWEEN库 +const TWEEN = require('./tween'); +// 导入自定义缓动函数库(OutIn 模式等官方未提供的组合) +const customEasings = require('./customEasings').customEasings; +// 导入Three.js 的 wrapper库 +const THREE = require('./three-amg-wrapper').THREE; +const { ShaderPass } = require('./ShaderPass.js'); +/** + * ScriptScene类 - 3D场景管理器 + * 负责创建和管理Three.js场景、相机、渲染器及场景对象 + */ +class ScriptScene { + /** + * 构造函数,创建场景管理器 + * @param {effect.Amaz.Scene} [amgScene] - AMG场景对象,可选参数 + * @param {HTMLElement} [container] - 放置渲染器的DOM容器,可选参数 + */ + constructor(amgScene = null, container = null) { + // 核心对象初始化 + if (amgScene) { + this.scene = new THREE.Scene(); + this.scene._amgScene = amgScene; + } else { + this.scene = new THREE.Scene(); + } + this.effect_type = "transition"; + this.camera = null; + this.renderer = null; + this.scene.background = new THREE.Color(0x333333); + this.isAnimating = false; + this.animationFrameId = null; + this.sceneObjects = null; + + this.texture1 = null; + this.texture2 = null; + + // 后处理相关属性 + this.composer = null; + this.renderPass = null; + this.usePostProcessing = true; // 是否启用后处理效果 + + // 初始化核心对象和基本场景 + this.initCoreObjects(); + if (container) { + this.init(container); + } + } + + /** + * 析构函数,清理场景并释放资源 + * 在不再需要场景时调用,确保正确释放内存和停止动画循环 + */ + destroy() { + // 停止动画循环 + this.isAnimating = false; + + // 取消动画帧请求 + if (this.animationFrameId !== null && typeof cancelAnimationFrame !== 'undefined') { + cancelAnimationFrame(this.animationFrameId); + this.animationFrameId = null; + } + + // 清理渲染器 + if (this.renderer) { + this.renderer.setAnimationLoop(null); + this.renderer.dispose(); + + // 移除渲染器的DOM元素 + if (this.renderer.domElement && this.renderer.domElement.parentNode) { + this.renderer.domElement.parentNode.removeChild(this.renderer.domElement); + } + } + + // 清理纹理资源 + if (this.texture1) { + if (typeof this.texture1.dispose === "function") this.texture1.dispose(); + this.texture1 = null; + } + if (this.texture2) { + if (typeof this.texture2.dispose === "function") this.texture2.dispose(); + this.texture2 = null; + } + + + + // 清理场景中的对象 + if (this.scene) { + this.scene.dispose(); + } + + // 移除窗口事件监听器 + if (typeof window !== 'undefined') { + window.removeEventListener('resize', this.handleResize); + } + + // 清理TWEEN动画 + if (this.sceneObjects && this.sceneObjects.tweens) { + this.sceneObjects.tweens.forEach(tween => { + if (tween && typeof tween.stop === 'function') { + tween.stop(); + } + }); + this.sceneObjects.tweens = []; + } + + // 清理多pass + if (this.shaderPasses && this.shaderPasses.length) { + this.shaderPasses.forEach((pass) => { + if (pass && typeof pass.dispose === "function") { + try { + pass.dispose(); + } catch (e) {} + } + }); + this.shaderPasses = []; + } + if (this.shaderPass && typeof this.shaderPass.dispose === "function") { + try { + this.shaderPass.dispose(); + } catch (e) {} + } + this.shaderPass = null; + // 清理后处理效果 + if (this.composer) { + this.composer.dispose(); + this.composer = null; + } + + this.renderPass = null; + + // 清理引用 + this.scene = null; + this.camera = null; + this.renderer = null; + this.sceneObjects = null; + } + + /** + * 初始化Three.js核心对象 + * 包括场景、相机和渲染器 + */ + initCoreObjects() { + if (typeof window !== "undefined") { + if (!window.innerWidth || !window.innerHeight) { + window.innerWidth = 600; + window.innerHeight = 600; + } + window.devicePixelRatio = window.devicePixelRatio || 1; + if (this.scene && this.scene._amgScene && this.scene._amgScene.assetMgr) { + const inputTexture = this.scene._amgScene.assetMgr.SyncLoad("share://input.texture"); + if (inputTexture && inputTexture.width > 0 && inputTexture.height > 0) { + window.innerWidth = inputTexture.width; + window.innerHeight = inputTexture.height; + } + } + } + this.camera = new THREE.PerspectiveCamera( + 53.1, // 视场角 + window.innerWidth / window.innerHeight, // 纵横比 + 0.1, // 近平面 + 10000 // 远平面 + ); + this.camera.position.z = 10; // 设置默认相机位置 + this.scene.add(this.camera); + + // 创建渲染器,启用抗锯齿 + // 当amgScene为null时,创建渲染器 + if (this.scene._amgScene == null) + { + this.renderer = new THREE.WebGLRenderer({ antialias: true }); + this.renderer.outputColorSpace = THREE.LinearSRGBColorSpace; + } + if (this.renderer) + { + this.renderer.setSize(window.innerWidth, window.innerHeight); + this.renderer.setPixelRatio(window.devicePixelRatio); + } + + // 滑竿列表 + this.sliders = {}; + + // 创建TWEEN实例 + this.TWEEN = TWEEN; + // 自定义缓动函数库:使用方式 this.customEasings.OutIn.Back 等 + this.customEasings = customEasings; + + // 时长 毫秒 + this.Duration = 2000; + } + + /** + * 添加ShaderPass + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + addShaderPass(shaderPassConfigs) { + if (!Array.isArray(shaderPassConfigs)) { + shaderPassConfigs = [shaderPassConfigs]; + } + + shaderPassConfigs.forEach(config => { + const atomicName = config.name; + const className = atomicName.startsWith('Lumi') ? atomicName.substring(4) : atomicName; + const shaderPassModule = require('../pp/Lumi' + className + '/' + className + 'ShaderPass.js'); + const ShaderPassClass = shaderPassModule[className + 'ShaderPass']; + const initConfig = (config && (config.initConfig || config.config || config.params)) || {}; + const shaderPass = new ShaderPassClass(initConfig); + // console.log('ShaderPass created:', shaderPass, className); + this.composer.addPass(shaderPass); + this.shaderPasses.push(shaderPass); + }); + } + + /** + * 设置后处理 + * @param {Array} shaderPassConfigs - ShaderPass配置数组 + * @return {void} + */ + setupPostProcessing(shaderPassConfigs) { + const { EffectComposer } = require('./EffectComposer.js'); + const { RenderPass } = require('./RenderPass.js'); + + // 创建后处理渲染目标 + this.composer = new EffectComposer(this.renderer); + this.renderPass = new RenderPass(this.scene, this.camera); + this.composer.addPass(this.renderPass); + this.shaderPasses = []; + + this.addShaderPass(shaderPassConfigs); + } + +//===begin_pp=== +initPostProcessing() {} +//===end_pp=== + + /** + * 初始化场景 + * 设置基本的Three.js环境,添加渲染器到DOM + * @param {HTMLElement} container - 放置渲染器的DOM容器 + */ + init(container) { + if (this.renderer) { + if (container) { + container.appendChild(this.renderer.domElement); + } else if (typeof document !== 'undefined') { + document.body.appendChild(this.renderer.domElement); + } + } + if (typeof window !== 'undefined') { + window.addEventListener('resize', () => this.handleResize()); + } + } + + /** + * 开始场景动画循环 + * @param {Function} updateCallback - 每帧调用的更新函数 + */ + start(updateCallback) { + if (this.isAnimating) return; + + this.isAnimating = true; + + // 如果提供了更新回调,使用requestAnimationFrame + if (updateCallback) { + const animateFrame = () => { + if (!this.isAnimating) return; + updateCallback(); + this.animationFrameId = requestAnimationFrame(animateFrame); + }; + + animateFrame(); + } else { + // 否则使用Three.js的setAnimationLoop,直接调用update渲染场景 + this.renderer.setAnimationLoop(() => { + this.update(); + }); + } + } + + + + /** + * 更新场景(由外部动画循环调用) + * @param {number} timestamp - 当前时间戳 + */ + updateScene(timestamp) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 直接调用默认更新函数,传入时间戳 + this.defaultUpdate(timestamp); + } + + /** + * 更新并渲染场景 + * 在每一帧调用,将当前场景通过渲染器绘制到屏幕 + */ + update() { + if (this.usePostProcessing && this.composer) { + // 确保composer使用当前活动的相机 + if (this.renderPass) { + this.renderPass.camera = this.camera; + } + + // 使用后处理效果渲染 + this.composer.render(); + } else if (this.renderer) { + // 直接渲染场景 + this.renderer.render(this.scene, this.camera); + } + } + + /** + * 窗口大小调整处理 + * 在窗口大小变化时调整相机和渲染器 + */ + handleResize() { + this.camera.aspect = window.innerWidth / window.innerHeight; + this.camera.updateProjectionMatrix(); + if (this.renderer) { + this.renderer.setSize(window.innerWidth, window.innerHeight); + } + + // 调整后处理效果的大小 + // if (this.composer) { + // this.composer.setSize(window.innerWidth, window.innerHeight); + // } + + // 如果不在动画循环中,触发一次渲染以更新视图 + if (!this.isAnimating) { + this.update(); + } + } + + loadTextures() { + const textureLoader = new THREE.TextureLoader(); + return Promise.all([ + new Promise(resolve => { + this.texture1 = textureLoader.load('image/Sample1.jpg', resolve); + this.texture1.colorSpace = THREE.LinearSRGBColorSpace; + this.texture1.wrapS = THREE.RepeatWrapping; + this.texture1.wrapT = THREE.RepeatWrapping; + }), + new Promise(resolve => { + this.texture2 = textureLoader.load('image/Sample2.jpg', resolve); + this.texture2.colorSpace = THREE.LinearSRGBColorSpace; + this.texture2.wrapS = THREE.RepeatWrapping; + this.texture2.wrapT = THREE.RepeatWrapping; + }) + ]); + } + + _applyTweenInitialState(tween) { + if (!tween._propertiesAreSetUp) { + tween.start(0); + } + if (!tween._valuesStart || !tween._valuesEnd) { + return; + } + tween._updateProperties(tween._object, tween._valuesStart, tween._valuesEnd, 0); + if (typeof tween._onUpdateCallback === 'function') { + tween._onUpdateCallback(tween._object, 0); + } + } + + _applyTweenFinalState(tween) { + if (!tween._propertiesAreSetUp) { + tween.start(0); + } + if (!tween._valuesStart || !tween._valuesEnd) { + return; + } + tween._updateProperties(tween._object, tween._valuesStart, tween._valuesEnd, 1); + if (typeof tween._onUpdateCallback === 'function') { + tween._onUpdateCallback(tween._object, 1); + } + } + + /** + * 根据时间直接设置动画状态(用于时间跳转) + * @param {number} time - 动画时间(毫秒) + */ + seekToTime(time) { + // 标记动画开始 + if (!this.isAnimating) { + this.isAnimating = true; + } + + // 限制时间范围 + const clampedTime = Math.max(0, Math.min(time, this.Duration)); + + // seek ShaderPass后处理逻辑,该函数已预先定义,无需生成_predef_seekShaderPass实现 + if (this._predef_seekShaderPass) + { + this._predef_seekShaderPass(clampedTime); + } + + if (!this.sceneObjects.tweens || this.sceneObjects.tweens.length === 0) { + return; + } + + // 使用逆序遍历 TWEEN,确保正确的属性覆盖优先级 + // 逆序处理:让开始时间晚的tween先处理,开始时间早的tween后处理并覆盖 + + let notStartTweens = []; + let runningTweens = []; + let finishedTweens = []; + + for (let i = 0; i <= this.sceneObjects.tweens.length - 1; i++) { + const tween = this.sceneObjects.tweens[i]; + + let TweenStartTime = tween._delayTime + 10; + let TweenEndTime = tween._delayTime + tween._duration; + + // 将tween分为三种,未开始,进行中,已结束 + // 分到3个列表中 + + if (clampedTime <= TweenStartTime) { + notStartTweens.push({time: TweenStartTime, tween: tween}); + } + else if (clampedTime >= TweenEndTime) { + finishedTweens.push({time: TweenEndTime, tween: tween}); + } + else + { + runningTweens.push(tween); + } + } + + // 按照开始时间排序 + notStartTweens.sort((a, b) => b.time - a.time); + // 按照结束时间排序 + finishedTweens.sort((a, b) => a.time - b.time); + + notStartTweens.forEach(item => { + this._applyTweenInitialState(item.tween); + }); + + finishedTweens.forEach(item => { + this._applyTweenFinalState(item.tween); + }); + + runningTweens.forEach(tween => { + tween.stop(); + tween.start(0); + tween.update(clampedTime); + }); + + this.update(); + } + +//===begin=== +//===滑竿begin=== +//===滑竿end=== +/** + * 初始化滑竿 + */ +setupSliders(){ +} + +/** + * 更新滑竿 + */ +updateSliders(){ +} + +/** + * 初始化一个完整的基本场景(不包含动画循环) + * 包括相机、场景对象的创建和特效材质 + * @returns {Object} 场景中的对象引用 + */ +setupScene() { + // 初始化场景对象容器 + this.initSceneObjects(); + + // 更新滑竿 + this.setupSliders(); + this.updateSliders(); + + // 设置场景背景为黑色 + this.scene.background = new THREE.Color(0x000000); + + // 创建效果平面 + this.createPlane(); + + // 设置动画 + this.setupAnimation(); + + return this.sceneObjects; +} + +/** + * 初始化场景对象容器 + */ +initSceneObjects() { + this.sceneObjects = { + plane: null, // 主平面对象 + material: null, // 效果材质 + tweens: [] // 动画对象数组 + }; +} + +/** + * 创建效果平面 + */ +createPlane() { + // 创建平面几何体,宽高比为1:1 + const geometry = new THREE.PlaneGeometry(10, 10, 100, 1); + + // 使用自定义着色器材质实现扫描线效果 + const material = this.createMaterial(); + this.sceneObjects.material = material; + + // 创建面片 + const plane = new THREE.Mesh(geometry, material); + plane.name = "Plane"; + this.sceneObjects.plane = plane; + + // 将面片添加到场景 + this.scene.add(plane); +} + +/** + * 创建效果平面的着色器材质 + * @returns {THREE.ShaderMaterial} 效果平面着色器材质 + */ +createMaterial() { + // 确保纹理已加载 + if (!this.texture1 || !this.texture2) { + console.error("纹理未加载!"); + return new THREE.MeshBasicMaterial({ color: 0xff0000 }); + } + + // 为纹理设置适当的参数 + this.texture1.minFilter = THREE.LinearFilter; + this.texture1.magFilter = THREE.LinearFilter; + this.texture1.wrapS = THREE.ClampToEdgeWrapping; + this.texture1.wrapT = THREE.ClampToEdgeWrapping; + + this.texture2.minFilter = THREE.LinearFilter; + this.texture2.magFilter = THREE.LinearFilter; + this.texture2.wrapS = THREE.ClampToEdgeWrapping; + this.texture2.wrapT = THREE.ClampToEdgeWrapping; + + // 创建自定义着色器材质 + this.shaderPass = new (require('../pp/LumiCustom/CustomShaderPass.js').CustomShaderPass)(); + var material = this.shaderPass.material; + // 传入默认纹理 + material.uniforms.tDiffuse.value = this.texture1; + material.uniforms.tDiffuse1.value = this.texture2; + return material; +} + +/** + * 设置动画 + */ +setupAnimation() { + if (!this.shaderPass) { + console.error("着色器传递对象未创建!"); + return; + } + if (typeof this.shaderPass.setParameter !== 'function') { + console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`); + return; + } + + const duration = this.Duration; // 使用已定义的持续时间 + const tweens = []; + this.sceneObjects.tweens = []; + + // 创建从0到1的动画 + const tween1 = new TWEEN.Tween({ intensity: 0, progress: 0 }) + .to({ intensity: 1, progress: 0.5 }, duration * 0.35) + .delay(duration * 0.15) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历obj中的所有属性,自动设置参数 + for (const key in obj) { + this.shaderPass.setParameter(key, obj[key]); + } + }); + + // 创建从1到0的动画 + const tween2 = new TWEEN.Tween({ intensity: 1, progress: 0.5 }) + .to({ intensity: 0, progress: 1 }, duration * 0.35) + .delay(duration * 0.5) + .easing(TWEEN.Easing.Linear.None) + .onUpdate((obj) => { + // 遍历obj中的所有属性,自动设置参数 + for (const key in obj) { + this.shaderPass.setParameter(key, obj[key]); + } + }); + + tweens.push(tween1, tween2); + + // 启动所有动画 + tweens.forEach(tween => tween.start()); + + // 存储动画对象引用 + if (tweens.length > 0) { + if (!this.sceneObjects.tweens) { + this.sceneObjects.tweens = []; + } + this.sceneObjects.tweens.push(...tweens); + } +} +//===end=== + + /** + * 默认的场景更新函数,实现轨道交错转场动画 + */ + defaultUpdate(timestamp) { + // 更新所有TWEEN动画 + if (this.sceneObjects.tweens && this.sceneObjects.tweens.length > 0) { + this.sceneObjects.tweens.forEach(tween => { + if (tween && typeof tween.update === 'function') { + tween.update(timestamp); + } + }); + } + + this.update(); + } + + //===Predefined Function Begin=== +_predef_addTopCenterBottomStyleBorder(parent, offset, texture, cutoutAreaPosition, cutoutAreaSize) { + const aspectRatio = this.texture1.image.width / this.texture1.image.height; + const parentInitScale = parent.scale.y; + const parentPosition = parent.position; + const textureWidth = texture.image.width; + const textureHeight = texture.image.height; + const geometry = new THREE.PlaneGeometry(10, 10); + + // center + const textureCenter = texture.clone(); + textureCenter.repeat.set(1, cutoutAreaSize.y / textureHeight); + textureCenter.offset.set(0, (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureHeight); + + const materialCenter = new THREE.MeshBasicMaterial({ + map: textureCenter, + transparent: true, + opacity: 1, + premultipliedAlpha: true, + side: THREE.DoubleSide + }); + materialCenter.name = 'PlaneCenterMaterial'; + + const planeCenter = new THREE.Mesh(geometry, materialCenter); + planeCenter.name = 'PlaneCenter'; + planeCenter.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y, parentPosition.z + offset.z); + planeCenter.scale.set(parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth), parentInitScale, 1); + + this.scene.add(planeCenter); + parent.attach(planeCenter); + + // top + const textureTop = texture.clone(); + textureTop.repeat.set(1, cutoutAreaPosition.y / textureHeight); + textureTop.offset.set(0, 1 - cutoutAreaPosition.y / textureHeight); + + const materialTop = new THREE.MeshBasicMaterial({ + map: textureTop, + transparent: true, + opacity: 1, + premultipliedAlpha: true, + side: THREE.DoubleSide + }); + materialTop.name = 'PlaneTopMaterial'; + + const scaleXTop = parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth); + const scaleYTop = scaleXTop * cutoutAreaPosition.y / textureWidth; + + const planeTop = new THREE.Mesh(geometry, materialTop); + planeTop.name = 'PlaneTop'; + planeTop.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y + parentInitScale * 10 * 0.5 + scaleYTop * 10 * 0.5, parentPosition.z + offset.z); + planeTop.scale.set(scaleXTop, scaleYTop, 1); + + this.scene.add(planeTop); + parent.attach(planeTop); + + // bottom + const textureBottom = texture.clone(); + textureBottom.repeat.set(1, (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureHeight); + textureBottom.offset.set(0, 0); + + const materialBottom = new THREE.MeshBasicMaterial({ + map: textureBottom, + transparent: true, + opacity: 1, + premultipliedAlpha: true, + side: THREE.DoubleSide + }); + materialBottom.name = 'PlaneBottomMaterial'; + + const scaleXBottom = parentInitScale * aspectRatio / (cutoutAreaSize.x / textureWidth); + const scaleYBottom = scaleXBottom * (textureHeight - cutoutAreaPosition.y - cutoutAreaSize.y) / textureWidth; + + const planeBottom = new THREE.Mesh(geometry, materialBottom); + planeBottom.name = 'PlaneBottom'; + planeBottom.position.set(parentPosition.x + offset.x, parentPosition.y + offset.y - parentInitScale * 10 * 0.5 - scaleYBottom * 10 * 0.5, parentPosition.z + offset.z); + planeBottom.scale.set(scaleXBottom, scaleYBottom, 1); + + this.scene.add(planeBottom); + parent.attach(planeBottom); +} +_predef_loadVideoTexture(path, loop, playbackRate) { + if (this.scene._amgScene == null) { + const video = document.createElement('video'); + video.src = path; + video.muted = true; + video.loop = loop; + //video.play(); + video.load(); + + // video.style.position = 'absolute'; + // video.style.top = '400px'; + // video.style.left = '0px'; + // video.style.width = '480px'; + // video.style.height = '360px'; + // video.style.zIndex = '100'; + // document.body.appendChild(video); + + const videoTexture = new THREE.VideoTexture(video); + videoTexture.currentTime = 0; + videoTexture.playbackRate = playbackRate; + + this.videoTexture = videoTexture; + + return videoTexture; + } else if (typeof this.scene._amgScene === 'string') { + return new THREE.Texture(); + } else { + const texture = new THREE.VideoTexture(path, loop, playbackRate); + texture.load(); + return texture; + } +} +_predef_seekVideoTexture(time) { + if (this.videoTexture != null) { + const videoTexture = this.videoTexture; + const video = videoTexture.image; + if (video.readyState >= 2) { + const textureProperties = this.renderer.properties.get(videoTexture); + var newTime = time / 1000 * videoTexture.playbackRate; + if (newTime < 0) { + newTime = 0; + } else if (newTime > video.duration) { + if (video.loop) { + newTime = newTime % video.duration; + } else { + newTime = video.duration; + } + } + if (textureProperties.__version == videoTexture.version) { + videoTexture.currentTime = newTime; + video.currentTime = videoTexture.currentTime; + } + } + } +} +_predef_seekShaderPass(time) { + if (!('shaderPasses' in this) || this.shaderPasses == null) { + return; + } + this.shaderPasses.forEach(shaderPass => { + if (shaderPass.constructor.name === 'AnimSeqLoadAndCropBlendShaderPass') { + if (this.texture1 && this.texture1.image) { + const ratio = this.texture1.image.width / this.texture1.image.height; + if (typeof shaderPass.setAspectRatio === 'function') { + shaderPass.setAspectRatio(ratio); + } + } + } + }) +}//===Predefined Function End=== +} + +// 导入Three.js库 +// module.exports = ScriptScene; + +// 导入Three.js 的 wrapper库 +exports.ScriptScene = ScriptScene; diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..a5fd4883bac974897a1c16105d092d5a770bfa4c --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1,399 @@ +/** + * ThreeJS 到 AMG 的包装器 + * 让基于ThreeJS开发的应用能够在AMG引擎上运行 + * 此包装器将ThreeJS的API转换为AMG引擎的调用,实现无缝迁移 + */ + +// 获取AMG引擎API +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz ? effect_api.getAmaz() : null; + +// 场景实例存取模块 +const { getCurrentScene, setCurrentScene, clearCurrentScene } = require('./wrapper/runtime'); + +// 模拟浏览器环境中的window对象,使ThreeJS代码能在非浏览器环境中运行 +if (typeof window === 'undefined') { + // 定义模拟的window对象 + const mockWindow = { + innerWidth: 720, + innerHeight: 1280, + devicePixelRatio: 1, + addEventListener: function(event, callback) { + // 空函数,模拟事件监听 + }, + requestAnimationFrame: function(callback) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + cancelAnimationFrame: function(id) { + // 空实现 + // 在实际环境中应该取消动画帧请求 + }, + removeEventListener: function(event, callback) { + // 空实现 + // 在实际环境中应该取消事件监听 + } + }; + + // 定义模拟的document对象 + const mockDocument = { + createElement: function(tagName) { + return { + style: {}, + setAttribute: function() {}, + appendChild: function() {} + }; + }, + body: { + appendChild: function() {} + } + }; + + // 获取全局对象的通用方法 + const getGlobalObject = function() { + if (typeof global !== 'undefined') return global; + if (typeof self !== 'undefined') return self; + if (typeof window !== 'undefined') return window; + if (typeof this !== 'undefined') return this; + return {}; // 回退选项 + }; + + // 将模拟对象挂载到全局 + const globalObj = getGlobalObject(); + globalObj.window = mockWindow; + globalObj.document = mockDocument; + globalObj.cancelAnimationFrame = mockWindow.cancelAnimationFrame; +} + +// 定义命名空间对象,类似于THREE +const THREE = {}; + +// 常量定义(从 wrapper/Constants 统一导入,避免重复定义) +const __THREE_CONSTS = require('./wrapper/Constants'); + +THREE.FrontSide = __THREE_CONSTS.FrontSide; +THREE.BackSide = __THREE_CONSTS.BackSide; +THREE.DoubleSide = __THREE_CONSTS.DoubleSide; +THREE.NoBlending = __THREE_CONSTS.NoBlending; +THREE.NormalBlending = __THREE_CONSTS.NormalBlending; +THREE.AdditiveBlending = __THREE_CONSTS.AdditiveBlending; +THREE.SubtractiveBlending = __THREE_CONSTS.SubtractiveBlending; +THREE.MultiplyBlending = __THREE_CONSTS.MultiplyBlending; +THREE.CustomBlending = __THREE_CONSTS.CustomBlending; +THREE.RepeatWrapping = __THREE_CONSTS.RepeatWrapping; +THREE.ClampToEdgeWrapping = __THREE_CONSTS.ClampToEdgeWrapping; +THREE.MirroredRepeatWrapping = __THREE_CONSTS.MirroredRepeatWrapping; + + + +const Vector2Wrapper = require('./wrapper/Vector2').Vector2; +const Vector3Wrapper = require('./wrapper/Vector3').Vector3; +const Vector4Wrapper = require('./wrapper/Vector4').Vector4; +const EulerWrapper = require('./wrapper/Euler').Euler; +const ColorWrapper = require('./wrapper/Color').Color; +const Matrix4Wrapper = require('./wrapper/Matrix4').Matrix4; +const QuaternionWrapper = require('./wrapper/Quaternion').Quaternion; +const MathUtilsWrapper = require('./wrapper/MathUtils').MathUtils; +const Box3Wrapper = require('./wrapper/Box3').Box3; +const Box2Wrapper = require('./wrapper/Box2').Box2; +const WebGLRendererWrapper = require('./wrapper/WebGLRenderer').WebGLRenderer; + +const Vector2 = Vector2Wrapper; +const Vector3 = Vector3Wrapper; +const Vector4 = Vector4Wrapper; +const Euler = EulerWrapper; +const Color = ColorWrapper; +const Matrix4 = Matrix4Wrapper; +const Quaternion = QuaternionWrapper; +const MathUtils = MathUtilsWrapper; +const Box3 = Box3Wrapper; +const Box2 = Box2Wrapper; +const WebGLRenderer = WebGLRendererWrapper; + + +const BufferGeometryWrapper = require('./wrapper/BufferGeometry').BufferGeometry; +const BufferAttributeWrapper = require('./wrapper/BufferAttribute').BufferAttribute; +const BoxGeometryWrapper = require('./wrapper/BoxGeometry').BoxGeometry; +const PlaneGeometryWrapper = require('./wrapper/PlaneGeometry').PlaneGeometry; +const SphereGeometryWrapper = require('./wrapper/SphereGeometry').SphereGeometry; +const CylinderGeometryWrapper = require('./wrapper/CylinderGeometry').CylinderGeometry; +const CapsuleGeometryWrapper = require('./wrapper/CapsuleGeometry').CapsuleGeometry; +const ShapeWrapper = require('./wrapper/Shape').Shape; +const ShapeGeometryWrapper = require('./wrapper/ShapeGeometry').ShapeGeometry; +const ExtrudeGeometryWrapper = require('./wrapper/ExtrudeGeometry').ExtrudeGeometry; +const CurvePathWrapper = require('./wrapper/CurvePath').CurvePath; +const LineCurveWrapper = require('./wrapper/CurvePath').LineCurve; + +const BufferGeometry = BufferGeometryWrapper; +const BufferAttribute = BufferAttributeWrapper; +const BoxGeometry = BoxGeometryWrapper; +const PlaneGeometry = PlaneGeometryWrapper; +const SphereGeometry = SphereGeometryWrapper; +const CylinderGeometry = CylinderGeometryWrapper; +const CapsuleGeometry = CapsuleGeometryWrapper; +const Shape = ShapeWrapper; +const ShapeGeometry = ShapeGeometryWrapper; +const ExtrudeGeometry = ExtrudeGeometryWrapper; +const CurvePath = CurvePathWrapper; +const LineCurve = LineCurveWrapper; + +const TextureWrapper = require('./wrapper/Texture').Texture; +const VideoTextureWrapper = require('./wrapper/Texture').VideoTexture; +const TextureLoaderWrapper = require('./wrapper/Texture').TextureLoader; + +const Texture = TextureWrapper; +const VideoTexture = VideoTextureWrapper; +const TextureLoader = TextureLoaderWrapper; + + +const MaterialWrapper = require('./wrapper/Material').Material; +const MeshBasicMaterialWrapper = require('./wrapper/MeshBasicMaterial').MeshBasicMaterial; +const ShaderMaterialWrapper = require('./wrapper/ShaderMaterial').ShaderMaterial; + +const Material = MaterialWrapper; +const MeshBasicMaterial = MeshBasicMaterialWrapper; +const ShaderMaterial = ShaderMaterialWrapper; + + +const Object3DWrapper = require('./wrapper/Object3D').Object3D; +const GroupWrapper = require('./wrapper/Group').Group; +const MeshWrapper = require('./wrapper/Mesh').MeshWrapper; +const PerspectiveCameraWrapper = require('./wrapper/PerspectiveCamera').PerspectiveCamera; + +const Object3D = Object3DWrapper; +const Group = GroupWrapper; +const Mesh = MeshWrapper; +const PerspectiveCamera = PerspectiveCameraWrapper; +/** + * 场景类 + * 管理场景中的所有对象 + */ +class Scene { + constructor() { + // this._amgScene = new Amaz.Scene(); + this._objects = []; + + // 将场景添加到AMG管理器 + // effect.Amaz.AmazingManager.addScene(this._amgScene); + + // 设置全局场景实例 + setCurrentScene(this); + + console.log('AMG scene created'); + } + + /** + * 添加对象到场景 + * 支持一次添加多个对象,如: scene.add(obj1, obj2, obj3) + * @param {...Object} objects - 要添加的对象(可变参数) + */ + add(...objects) { + // 遍历所有传入的对象 + for (let i = 0; i < objects.length; i++) { + const object = objects[i]; + + if (!object) { + console.warn('Scene: 尝试添加空对象'); + continue; + } + + if (object._amgEntity) { + if (this._objects.indexOf(object) === -1) { + this._objects.push(object); + if (this._amgScene) { + if (object._transform.parent) { + object._transform.parent.removeTransform(object._transform); + } + object._transform.parent = null; + this._amgScene.addEntity(object._amgEntity); + } + console.log('Scene: added object to scene:', object._amgEntity.name); + } + else { + console.log('Scene: object already exists:', object._amgEntity.name); + } + } else { + console.warn('Scene: 添加到场景的对象没有_amgEntity属性'); + } + } + } + + /** + * 从场景中移除对象,不删除AMG实体 + * @param {Object} object - 要移除的对象 + */ + remove(object) { + const index = this._objects.indexOf(object); + if (index !== -1) { + this._objects.splice(index, 1); + console.log('Scene: removed object from scene, not delete AMG entity.'); + } + } + + /** + * 从场景中删除对象,删除AMG实体 + */ + delete(object) { + const index = this._objects.indexOf(object); + if (index !== -1) { + this._objects.splice(index, 1); + if (object._amgEntity) { + this._amgScene.removeEntity(object._amgEntity); + } + console.log('Scene: delete object from scene, delete AMG entity.'); + } + } + + /** + * 更新场景中的所有对象 + */ + update() { + // 更新场景中的所有对象 + this._objects.forEach(obj => obj.update && obj.update()); + } + + seekToTime(time) { + this._objects.forEach(obj => obj.seekToTime && obj.seekToTime(time)); + } + + /** + * 析构函数,清理场景资源 + * 在不再需要场景时调用,确保释放所有资源并从AMG管理器中移除 + */ + dispose() { + console.log('Scene: 开始清理场景资源'); + + // 清理所有对象 + while (this._objects.length > 0) { + const object = this._objects[0]; + this.delete(object); + + // 如果对象有自己的dispose方法,调用它 + if (object.dispose && typeof object.dispose === 'function') { + object.dispose(); + } + + // 释放几何体和材质 + if (object.geometry && object.geometry.dispose) { + object.geometry.dispose(); + } + + if (object.material) { + if (Array.isArray(object.material)) { + object.material.forEach(material => { + if (material.dispose) material.dispose(); + }); + } else if (object.material.dispose) { + object.material.dispose(); + } + } + } + + // 从AMG管理器中移除场景 + if (this._amgScene) { + this._amgScene = null; + } + + // 清空对象数组 + this._objects = []; + + // 如果当前全局场景是这个场景,重置它 + if (getCurrentScene() === this) { + clearCurrentScene(); + } + + console.log('Scene: 场景资源清理完成'); + } +} + +class QuadraticBezierCurve3 { + constructor(p0, p1, p2) { + this.p0 = p0; + this.p1 = p1; + this.p2 = p2; + } + + getPoint(t) { + // 二次贝塞尔曲线公式: B(t) = (1-t)²P₀ + 2(1-t)tP₁ + t²P₂ + const u = 1 - t; + const tt = t * t; + const uu = u * u; + const ut2 = 2 * u * t; + + return new Vector3( + uu * this.p0.x + ut2 * this.p1.x + tt * this.p2.x, + uu * this.p0.y + ut2 * this.p1.y + tt * this.p2.y, + uu * this.p0.z + ut2 * this.p1.z + tt * this.p2.z + ); + } + + getPoints(divisions) { + const points = []; + for (let i = 0; i <= divisions; i++) { + points.push(this.getPoint(i / divisions)); + } + return points; + } +} + + +/** #region 基础数学与类型 */ +THREE.Vector2 = Vector2; +THREE.Vector3 = Vector3; +THREE.Vector4 = Vector4; +THREE.Euler = Euler; +THREE.Color = Color; +THREE.Matrix4 = Matrix4; +THREE.Quaternion = Quaternion; +THREE.QuadraticBezierCurve3 = QuadraticBezierCurve3; +THREE.Box3 = Box3; +THREE.Box2 = Box2; +THREE.MathUtils = MathUtils; +/** #endregion 基础数学与类型 */ + +/** #region 场景与相机 */ +THREE.Scene = Scene; +/** #endregion 场景与相机 */ + +/** #region 渲染器 */ +THREE.WebGLRenderer = WebGLRenderer; +/** #endregion 渲染器 */ + +/** #region 几何体与属性 */ +THREE.BufferGeometry = BufferGeometry; +THREE.BufferAttribute = BufferAttribute; +THREE.Float32BufferAttribute = BufferAttribute; +THREE.BoxGeometry = BoxGeometry; +THREE.PlaneGeometry = PlaneGeometry; +THREE.SphereGeometry = SphereGeometry; +THREE.CylinderGeometry = CylinderGeometry; +THREE.CapsuleGeometry = CapsuleGeometry; +THREE.Shape = Shape; +THREE.ShapeGeometry = ShapeGeometry; +THREE.ExtrudeGeometry = ExtrudeGeometry; +THREE.CurvePath = CurvePath; +THREE.LineCurve = LineCurve; +/** #endregion 几何体与属性 */ + +/** #region 材质与着色 */ +THREE.Material = Material; +THREE.MeshBasicMaterial = MeshBasicMaterial; +THREE.ShaderMaterial = ShaderMaterial; +/** #endregion 材质与着色 */ + +/** #region 纹理相关 */ +THREE.Texture = Texture; +THREE.VideoTexture = VideoTexture; +THREE.TextureLoader = TextureLoader; +/** #endregion 纹理相关 */ + +/** #region 物体与层级 */ +THREE.Object3D = Group; +THREE.Group = Group; +THREE.Mesh = Mesh; +THREE.PerspectiveCamera = PerspectiveCamera; +/** #endregion 物体与层级 */ + +// 导出THREE命名空间和工具函数 +exports.THREE = THREE; +exports.getCurrentScene = getCurrentScene; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..e66c48c1214e9291408c0279764dfea2a447c79c --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1,1455 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/** + * The Ease class provides a collection of easing functions for use with tween.js. + */ +var Easing = Object.freeze({ + Linear: Object.freeze({ + None: function (amount) { + return amount; + }, + In: function (amount) { + return amount; + }, + Out: function (amount) { + return amount; + }, + InOut: function (amount) { + return amount; + }, + }), + Quadratic: Object.freeze({ + In: function (amount) { + return amount * amount; + }, + Out: function (amount) { + return amount * (2 - amount); + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount; + } + return -0.5 * (--amount * (amount - 2) - 1); + }, + }), + Cubic: Object.freeze({ + In: function (amount) { + return amount * amount * amount; + }, + Out: function (amount) { + return --amount * amount * amount + 1; + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount * amount; + } + return 0.5 * ((amount -= 2) * amount * amount + 2); + }, + }), + Quartic: Object.freeze({ + In: function (amount) { + return amount * amount * amount * amount; + }, + Out: function (amount) { + return 1 - --amount * amount * amount * amount; + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount * amount * amount; + } + return -0.5 * ((amount -= 2) * amount * amount * amount - 2); + }, + }), + Quintic: Object.freeze({ + In: function (amount) { + return amount * amount * amount * amount * amount; + }, + Out: function (amount) { + return --amount * amount * amount * amount * amount + 1; + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return 0.5 * amount * amount * amount * amount * amount; + } + return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); + }, + }), + Sinusoidal: Object.freeze({ + In: function (amount) { + return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2); + }, + Out: function (amount) { + return Math.sin((amount * Math.PI) / 2); + }, + InOut: function (amount) { + return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount))); + }, + }), + Exponential: Object.freeze({ + In: function (amount) { + return amount === 0 ? 0 : Math.pow(1024, amount - 1); + }, + Out: function (amount) { + return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount); + }, + InOut: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + if ((amount *= 2) < 1) { + return 0.5 * Math.pow(1024, amount - 1); + } + return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2); + }, + }), + Circular: Object.freeze({ + In: function (amount) { + return 1 - Math.sqrt(1 - amount * amount); + }, + Out: function (amount) { + return Math.sqrt(1 - --amount * amount); + }, + InOut: function (amount) { + if ((amount *= 2) < 1) { + return -0.5 * (Math.sqrt(1 - amount * amount) - 1); + } + return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1); + }, + }), + Elastic: Object.freeze({ + In: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); + }, + Out: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1; + }, + InOut: function (amount) { + if (amount === 0) { + return 0; + } + if (amount === 1) { + return 1; + } + amount *= 2; + if (amount < 1) { + return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); + } + return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1; + }, + }), + Back: Object.freeze({ + In: function (amount) { + var s = 1.70158; + return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s); + }, + Out: function (amount) { + var s = 1.70158; + return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1; + }, + InOut: function (amount) { + var s = 1.70158 * 1.525; + if ((amount *= 2) < 1) { + return 0.5 * (amount * amount * ((s + 1) * amount - s)); + } + return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2); + }, + }), + Bounce: Object.freeze({ + In: function (amount) { + return 1 - Easing.Bounce.Out(1 - amount); + }, + Out: function (amount) { + if (amount < 1 / 2.75) { + return 7.5625 * amount * amount; + } + else if (amount < 2 / 2.75) { + return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75; + } + else if (amount < 2.5 / 2.75) { + return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; + } + else { + return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; + } + }, + InOut: function (amount) { + if (amount < 0.5) { + return Easing.Bounce.In(amount * 2) * 0.5; + } + return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; + }, + }), + generatePow: function (power) { + if (power === void 0) { power = 4; } + power = power < Number.EPSILON ? Number.EPSILON : power; + power = power > 10000 ? 10000 : power; + return { + In: function (amount) { + return Math.pow(amount, power); + }, + Out: function (amount) { + return 1 - Math.pow((1 - amount), power); + }, + InOut: function (amount) { + if (amount < 0.5) { + return Math.pow((amount * 2), power) / 2; + } + return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5; + }, + }; + }, +}); + +var now = function () { + // 优先使用原生performance.now() + // if (typeof performance !== 'undefined' && performance.now) { + // return performance.now(); + // } + + // Node.js环境:使用高精度时间 + if (typeof process !== 'undefined' && process.hrtime) { + if (!now._nodeStartTime) { + now._nodeStartTime = process.hrtime(); + } + var hrTime = process.hrtime(now._nodeStartTime); + return hrTime[0] * 1000 + hrTime[1] / 1000000; + } + + // 浏览器兜底:模拟performance.now()行为 + if (typeof now._startTime === 'undefined') { + now._startTime = Date.now(); + now._lastReturned = 0; + } + + var elapsed = Date.now() - now._startTime; + + // 确保时间单调递增,同时添加微小递增来模拟高精度 + if (elapsed <= now._lastReturned) { + now._lastReturned += 0.001; + } else { + now._lastReturned = elapsed; + } + + return now._lastReturned; +}; +function setNow(nowFunction) { + _nowFunc = nowFunction; +} + +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tween + */ +var Group = /** @class */ (function () { + function Group() { + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + this._tweens = {}; + this._tweensAddedDuringUpdate = {}; + this.add.apply(this, tweens); + } + Group.prototype.getAll = function () { + var _this = this; + return Object.keys(this._tweens).map(function (tweenId) { return _this._tweens[tweenId]; }); + }; + Group.prototype.removeAll = function () { + this._tweens = {}; + }; + Group.prototype.add = function () { + var _a; + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) { + var tween = tweens_1[_b]; + // Remove from any other group first, a tween can only be in one group at a time. + // @ts-expect-error library internal access + (_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween); + // @ts-expect-error library internal access + tween._group = this; + this._tweens[tween.getId()] = tween; + this._tweensAddedDuringUpdate[tween.getId()] = tween; + } + }; + Group.prototype.remove = function () { + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) { + var tween = tweens_2[_a]; + // @ts-expect-error library internal access + tween._group = undefined; + delete this._tweens[tween.getId()]; + delete this._tweensAddedDuringUpdate[tween.getId()]; + } + }; + /** Return true if all tweens in the group are not paused or playing. */ + Group.prototype.allStopped = function () { + return this.getAll().every(function (tween) { return !tween.isPlaying(); }); + }; + Group.prototype.update = function (time, preserve) { + if (time === void 0) { time = now(); } + if (preserve === void 0) { preserve = true; } + var tweenIds = Object.keys(this._tweens); + if (tweenIds.length === 0) + return; + // Tweens are updated in "batches". If you add a new tween during an + // update, then the new tween will be updated in the next batch. + // If you remove a tween during an update, it may or may not be updated. + // However, if the removed tween was added during the current batch, + // then it will not be updated. + while (tweenIds.length > 0) { + this._tweensAddedDuringUpdate = {}; + for (var i = 0; i < tweenIds.length; i++) { + var tween = this._tweens[tweenIds[i]]; + var autoStart = !preserve; + if (tween && tween.update(time, autoStart) === false && !preserve) + this.remove(tween); + } + tweenIds = Object.keys(this._tweensAddedDuringUpdate); + } + }; + Group.prototype.onComplete = function (callback) { + var group = this.getAll(); + group.forEach(function (tween) { + var prevCallback = tween.getCompleteCallback(); + tween.onComplete(function () { + prevCallback === null || prevCallback === void 0 ? void 0 : prevCallback(tween); + // After the onComplete callback completes, _isPlaying is updated to false, so if the total number of completed tweens is -1, then they are all complete. + var completedGroup = group.filter(function (tween) { return !tween.isPlaying(); }); + if (completedGroup.length === group.length - 1) + callback(group); + }); + }); + }; + return Group; +}()); + +/** + * + */ +var Interpolation = { + Linear: function (v, k) { + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + var fn = Interpolation.Utils.Linear; + if (k < 0) { + return fn(v[0], v[1], f); + } + if (k > 1) { + return fn(v[m], v[m - 1], m - f); + } + return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); + }, + Bezier: function (v, k) { + var b = 0; + var n = v.length - 1; + var pw = Math.pow; + var bn = Interpolation.Utils.Bernstein; + for (var i = 0; i <= n; i++) { + b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); + } + return b; + }, + CatmullRom: function (v, k) { + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + var fn = Interpolation.Utils.CatmullRom; + if (v[0] === v[m]) { + if (k < 0) { + i = Math.floor((f = m * (1 + k))); + } + return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); + } + else { + if (k < 0) { + return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); + } + if (k > 1) { + return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); + } + return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); + } + }, + Utils: { + Linear: function (p0, p1, t) { + return (p1 - p0) * t + p0; + }, + Bernstein: function (n, i) { + var fc = Interpolation.Utils.Factorial; + return fc(n) / fc(i) / fc(n - i); + }, + Factorial: (function () { + var a = [1]; + return function (n) { + var s = 1; + if (a[n]) { + return a[n]; + } + for (var i = n; i > 1; i--) { + s *= i; + } + a[n] = s; + return s; + }; + })(), + CatmullRom: function (p0, p1, p2, p3, t) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; + }, + }, +}; + +/** + * Utils + */ +var Sequence = /** @class */ (function () { + function Sequence() { + } + Sequence.nextId = function () { + return Sequence._nextId++; + }; + Sequence._nextId = 0; + return Sequence; +}()); + +var mainGroup = new Group(); + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var Tween = /** @class */ (function () { + function Tween(object, group) { + this._isPaused = false; + this._pauseStart = 0; + this._valuesStart = {}; + this._valuesEnd = {}; + this._valuesStartRepeat = {}; + this._duration = 1000; + this._isDynamic = false; + this._initialRepeat = 0; + this._repeat = 0; + this._yoyo = false; + this._isPlaying = false; + this._reversed = false; + this._delayTime = 0; + this._startTime = 0; + this._easingFunction = Easing.Linear.None; + this._interpolationFunction = Interpolation.Linear; + // eslint-disable-next-line + this._chainedTweens = []; + this._onStartCallbackFired = false; + this._onEveryStartCallbackFired = false; + this._id = Sequence.nextId(); + this._isChainStopped = false; + this._propertiesAreSetUp = false; + this._goToEnd = false; + this._object = object; + if (typeof group === 'object') { + this._group = group; + group.add(this); + } + // Use "true" to restore old behavior (will be removed in future release). + else if (group === true) { + this._group = mainGroup; + mainGroup.add(this); + } + } + Tween.prototype.getId = function () { + return this._id; + }; + Tween.prototype.getCompleteCallback = function () { + return this._onCompleteCallback; + }; + Tween.prototype.isPlaying = function () { + return this._isPlaying; + }; + Tween.prototype.isPaused = function () { + return this._isPaused; + }; + Tween.prototype.getDuration = function () { + return this._duration; + }; + Tween.prototype.to = function (target, duration) { + if (duration === void 0) { duration = 1000; } + if (this._isPlaying) + throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.'); + this._valuesEnd = target; + this._propertiesAreSetUp = false; + this._duration = duration < 0 ? 0 : duration; + return this; + }; + Tween.prototype.duration = function (duration) { + if (duration === void 0) { duration = 1000; } + this._duration = duration < 0 ? 0 : duration; + return this; + }; + Tween.prototype.dynamic = function (dynamic) { + if (dynamic === void 0) { dynamic = false; } + this._isDynamic = dynamic; + return this; + }; + Tween.prototype.start = function (time, overrideStartingValues) { + if (time === void 0) { time = now(); } + if (overrideStartingValues === void 0) { overrideStartingValues = false; } + if (this._isPlaying) { + return this; + } + this._repeat = this._initialRepeat; + if (this._reversed) { + // If we were reversed (f.e. using the yoyo feature) then we need to + // flip the tween direction back to forward. + this._reversed = false; + for (var property in this._valuesStartRepeat) { + this._swapEndStartRepeatValues(property); + this._valuesStart[property] = this._valuesStartRepeat[property]; + } + } + this._isPlaying = true; + this._isPaused = false; + this._onStartCallbackFired = false; + this._onEveryStartCallbackFired = false; + this._isChainStopped = false; + this._startTime = time; + this._startTime += this._delayTime; + if (!this._propertiesAreSetUp || overrideStartingValues) { + this._propertiesAreSetUp = true; + // If dynamic is not enabled, clone the end values instead of using the passed-in end values. + if (!this._isDynamic) { + var tmp = {}; + for (var prop in this._valuesEnd) + tmp[prop] = this._valuesEnd[prop]; + this._valuesEnd = tmp; + } + this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues); + } + return this; + }; + Tween.prototype.startFromCurrentValues = function (time) { + return this.start(time, true); + }; + Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) { + for (var property in _valuesEnd) { + var startValue = _object[property]; + var startValueIsArray = Array.isArray(startValue); + var propType = startValueIsArray ? 'array' : typeof startValue; + var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]); + // If `to()` specifies a property that doesn't exist in the source object, + // we should not set that property in the object + if (propType === 'undefined' || propType === 'function') { + continue; + } + // Check if an Array was provided as property value + if (isInterpolationList) { + var endValues = _valuesEnd[property]; + if (endValues.length === 0) { + continue; + } + // Handle an array of relative values. + // Creates a local copy of the Array with the start value at the front + var temp = [startValue]; + for (var i = 0, l = endValues.length; i < l; i += 1) { + var value = this._handleRelativeValue(startValue, endValues[i]); + if (isNaN(value)) { + isInterpolationList = false; + console.warn('Found invalid interpolation list. Skipping.'); + break; + } + temp.push(value); + } + if (isInterpolationList) { + // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp. + _valuesEnd[property] = temp; + // } + } + } + // handle the deepness of the values + if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { + _valuesStart[property] = startValueIsArray ? [] : {}; + var nestedObject = startValue; + for (var prop in nestedObject) { + _valuesStart[property][prop] = nestedObject[prop]; + } + // TODO? repeat nested values? And yoyo? And array values? + _valuesStartRepeat[property] = startValueIsArray ? [] : {}; + var endValues = _valuesEnd[property]; + // If dynamic is not enabled, clone the end values instead of using the passed-in end values. + if (!this._isDynamic) { + var tmp = {}; + for (var prop in endValues) + tmp[prop] = endValues[prop]; + _valuesEnd[property] = endValues = tmp; + } + this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues); + } + else { + // Save the starting value, but only once unless override is requested. + if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) { + _valuesStart[property] = startValue; + } + if (!startValueIsArray) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings + } + if (isInterpolationList) { + // eslint-disable-next-line + // @ts-ignore FIXME? + _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse(); + } + else { + _valuesStartRepeat[property] = _valuesStart[property] || 0; + } + } + } + }; + Tween.prototype.stop = function () { + if (!this._isChainStopped) { + this._isChainStopped = true; + this.stopChainedTweens(); + } + if (!this._isPlaying) { + return this; + } + this._isPlaying = false; + this._isPaused = false; + if (this._onStopCallback) { + this._onStopCallback(this._object); + } + return this; + }; + Tween.prototype.end = function () { + this._goToEnd = true; + this.update(this._startTime + this._duration); + return this; + }; + Tween.prototype.pause = function (time) { + if (time === void 0) { time = now(); } + if (this._isPaused || !this._isPlaying) { + return this; + } + this._isPaused = true; + this._pauseStart = time; + return this; + }; + Tween.prototype.resume = function (time) { + if (time === void 0) { time = now(); } + if (!this._isPaused || !this._isPlaying) { + return this; + } + this._isPaused = false; + this._startTime += time - this._pauseStart; + this._pauseStart = 0; + return this; + }; + Tween.prototype.stopChainedTweens = function () { + for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { + this._chainedTweens[i].stop(); + } + return this; + }; + Tween.prototype.group = function (group) { + if (!group) { + console.warn('tween.group() without args has been removed, use group.add(tween) instead.'); + return this; + } + group.add(this); + return this; + }; + /** + * Removes the tween from whichever group it is in. + */ + Tween.prototype.remove = function () { + var _a; + (_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this); + return this; + }; + Tween.prototype.delay = function (amount) { + if (amount === void 0) { amount = 0; } + this._delayTime = amount; + return this; + }; + Tween.prototype.repeat = function (times) { + if (times === void 0) { times = 0; } + this._initialRepeat = times; + this._repeat = times; + return this; + }; + Tween.prototype.repeatDelay = function (amount) { + this._repeatDelayTime = amount; + return this; + }; + Tween.prototype.yoyo = function (yoyo) { + if (yoyo === void 0) { yoyo = false; } + this._yoyo = yoyo; + return this; + }; + Tween.prototype.easing = function (easingFunction) { + if (easingFunction === void 0) { easingFunction = Easing.Linear.None; } + this._easingFunction = easingFunction; + return this; + }; + Tween.prototype.interpolation = function (interpolationFunction) { + if (interpolationFunction === void 0) { interpolationFunction = Interpolation.Linear; } + this._interpolationFunction = interpolationFunction; + return this; + }; + // eslint-disable-next-line + Tween.prototype.chain = function () { + var tweens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tweens[_i] = arguments[_i]; + } + this._chainedTweens = tweens; + return this; + }; + Tween.prototype.onStart = function (callback) { + this._onStartCallback = callback; + return this; + }; + Tween.prototype.onEveryStart = function (callback) { + this._onEveryStartCallback = callback; + return this; + }; + Tween.prototype.onUpdate = function (callback) { + this._onUpdateCallback = callback; + return this; + }; + Tween.prototype.onRepeat = function (callback) { + this._onRepeatCallback = callback; + return this; + }; + Tween.prototype.onComplete = function (callback) { + this._onCompleteCallback = callback; + return this; + }; + Tween.prototype.onStop = function (callback) { + this._onStopCallback = callback; + return this; + }; + /** + * @returns true if the tween is still playing after the update, false + * otherwise (calling update on a paused tween still returns true because + * it is still playing, just paused). + * + * @param autoStart - When true, calling update will implicitly call start() + * as well. Note, if you stop() or end() the tween, but are still calling + * update(), it will start again! + */ + Tween.prototype.update = function (time, autoStart) { + var _this = this; + var _a; + if (time === void 0) { time = now(); } + if (autoStart === void 0) { autoStart = Tween.autoStartOnUpdate; } + if (this._isPaused) + return true; + var property; + if (!this._goToEnd && !this._isPlaying) { + if (autoStart) + this.start(time, true); + else + return false; + } + this._goToEnd = false; + if (time < this._startTime) { + return true; + } + if (this._onStartCallbackFired === false) { + if (this._onStartCallback) { + this._onStartCallback(this._object); + } + this._onStartCallbackFired = true; + } + if (this._onEveryStartCallbackFired === false) { + if (this._onEveryStartCallback) { + this._onEveryStartCallback(this._object); + } + this._onEveryStartCallbackFired = true; + } + var elapsedTime = time - this._startTime; + var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime); + var totalTime = this._duration + this._repeat * durationAndDelay; + var calculateElapsedPortion = function () { + if (_this._duration === 0) + return 1; + if (elapsedTime > totalTime) { + return 1; + } + var timesRepeated = Math.trunc(elapsedTime / durationAndDelay); + var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay; + // TODO use %? + // const timeIntoCurrentRepeat = elapsedTime % durationAndDelay + var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1); + if (portion === 0 && elapsedTime === _this._duration) { + return 1; + } + return portion; + }; + var elapsed = calculateElapsedPortion(); + var value = this._easingFunction(elapsed); + // properties transformations + this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value); + if (this._onUpdateCallback) { + this._onUpdateCallback(this._object, elapsed); + } + if (this._duration === 0 || elapsedTime >= this._duration) { + if (this._repeat > 0) { + var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat); + if (isFinite(this._repeat)) { + this._repeat -= completeCount; + } + // Reassign starting values, restart by making startTime = now + for (property in this._valuesStartRepeat) { + if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { + this._valuesStartRepeat[property] = + // eslint-disable-next-line + // @ts-ignore FIXME? + this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); + } + if (this._yoyo) { + this._swapEndStartRepeatValues(property); + } + this._valuesStart[property] = this._valuesStartRepeat[property]; + } + if (this._yoyo) { + this._reversed = !this._reversed; + } + this._startTime += durationAndDelay * completeCount; + if (this._onRepeatCallback) { + this._onRepeatCallback(this._object); + } + this._onEveryStartCallbackFired = false; + return true; + } + else { + if (this._onCompleteCallback) { + this._onCompleteCallback(this._object); + } + for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { + // Make the chained tweens start exactly at the time they should, + // even if the `update()` method was called way past the duration of the tween + this._chainedTweens[i].start(this._startTime + this._duration, false); + } + this._isPlaying = false; + return false; + } + } + return true; + }; + Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) { + for (var property in _valuesEnd) { + // Don't update properties that do not exist in the source object + if (_valuesStart[property] === undefined) { + continue; + } + var start = _valuesStart[property] || 0; + var end = _valuesEnd[property]; + var startIsArray = Array.isArray(_object[property]); + var endIsArray = Array.isArray(end); + var isInterpolationList = !startIsArray && endIsArray; + if (isInterpolationList) { + _object[property] = this._interpolationFunction(end, value); + } + else if (typeof end === 'object' && end) { + // eslint-disable-next-line + // @ts-ignore FIXME? + this._updateProperties(_object[property], start, end, value); + } + else { + // Parses relative end values with start as base (e.g.: +10, -3) + end = this._handleRelativeValue(start, end); + // Protect against non numeric properties. + if (typeof end === 'number') { + // eslint-disable-next-line + // @ts-ignore FIXME? + _object[property] = start + (end - start) * value; + } + } + } + }; + Tween.prototype._handleRelativeValue = function (start, end) { + if (typeof end !== 'string') { + return end; + } + if (end.charAt(0) === '+' || end.charAt(0) === '-') { + return start + parseFloat(end); + } + return parseFloat(end); + }; + Tween.prototype._swapEndStartRepeatValues = function (property) { + var tmp = this._valuesStartRepeat[property]; + var endValue = this._valuesEnd[property]; + if (typeof endValue === 'string') { + this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue); + } + else { + this._valuesStartRepeat[property] = this._valuesEnd[property]; + } + this._valuesEnd[property] = tmp; + }; + Tween.autoStartOnUpdate = false; + return Tween; +}()); + +var VERSION = '25.0.0'; + +/** + * Tween.js - Licensed under the MIT license + * https://github.com/tweenjs/tween.js + * ---------------------------------------------- + * + * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! + */ +var nextId = Sequence.nextId; +/** + * Controlling groups of tweens + * + * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. + * In these cases, you may want to create your own smaller groups of tweens. + */ +var TWEEN = mainGroup; +// This is the best way to export things in a way that's compatible with both ES +// Modules and CommonJS, without build hacks, and so as not to break the +// existing API. +// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881 +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var getAll = TWEEN.getAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var removeAll = TWEEN.removeAll.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var add = TWEEN.add.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var remove = TWEEN.remove.bind(TWEEN); +/** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ +var update = TWEEN.update.bind(TWEEN); +var exports$1 = { + Easing: Easing, + Group: Group, + Interpolation: Interpolation, + now: now, + setNow: setNow, + Sequence: Sequence, + nextId: nextId, + Tween: Tween, + VERSION: VERSION, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + getAll: getAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + removeAll: removeAll, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + add: add, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + remove: remove, + /** + * @deprecated The global TWEEN Group will be removed in a following major + * release. To migrate, create a `new Group()` instead of using `TWEEN` as a + * group. + * + * Old code: + * + * ```js + * import * as TWEEN from '@tweenjs/tween.js' + * + * //... + * + * const tween = new TWEEN.Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * TWEEN.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + * + * New code: + * + * ```js + * import {Tween, Group} from '@tweenjs/tween.js' + * + * //... + * + * const tween = new Tween(obj) + * const tween2 = new TWEEN.Tween(obj2) + * + * //... + * + * const group = new Group() + * group.add(tween) + * group.add(tween2) + * + * //... + * + * requestAnimationFrame(function loop(time) { + * group.update(time) + * requestAnimationFrame(loop) + * }) + * ``` + */ + update: update, +}; + +exports.Easing = Easing; +exports.Group = Group; +exports.Interpolation = Interpolation; +exports.Sequence = Sequence; +exports.Tween = Tween; +exports.VERSION = VERSION; +exports.add = add; +exports.default = exports$1; +exports.getAll = getAll; +exports.nextId = nextId; +exports.now = now; +exports.remove = remove; +exports.removeAll = removeAll; +exports.setNow = setNow; +exports.update = update; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Box2.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Box2.js new file mode 100644 index 0000000000000000000000000000000000000000..eb886973d02e86c0cb5201c6f1d953ce3c587e74 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Box2.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Box2{constructor(min,max){this.min=min!==undefined?min:new Vector2(Infinity,Infinity);this.max=max!==undefined?max:new Vector2(-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this}isEmpty(){return this.max.xthis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)= 1.0) return texel2; + + float p = smoothstep(0.0, 1.0, progress); + float midBoost = 1.0 - abs(2.0 * p - 1.0); + + vec2 cell = floor(vUv * vec2(gridScale * ratio, gridScale)); + float rnd = hash21(cell + floor(vec2(p * 24.0, p * 17.0))); + + float jitter = (rnd - 0.5) * 0.10 * glitchStrength * midBoost; + float wave = sin(vUv.y * 120.0 + rnd * 6.2831853) * 0.004 * glitchStrength * midBoost; + + vec2 dir = vec2(1.0 / max(ratio, 0.001), 0.0); + vec2 uvA = clamp(vUv + dir * (jitter + wave) * (1.0 - p), 0.0, 1.0); + vec2 uvB = clamp(vUv - dir * (jitter + wave) * p, 0.0, 1.0); + + float ca = chromaAmount * glitchStrength * midBoost * 0.02; + + vec3 colA; + colA.r = texture2D(tDiffuse, clamp(uvA + vec2(ca, 0.0), 0.0, 1.0)).r; + colA.g = texture2D(tDiffuse, uvA).g; + colA.b = texture2D(tDiffuse, clamp(uvA - vec2(ca, 0.0), 0.0, 1.0)).b; + + vec3 colB; + colB.r = texture2D(tDiffuse1, clamp(uvB - vec2(ca, 0.0), 0.0, 1.0)).r; + colB.g = texture2D(tDiffuse1, uvB).g; + colB.b = texture2D(tDiffuse1, clamp(uvB + vec2(ca, 0.0), 0.0, 1.0)).b; + + float edgeBase = p + (rnd - 0.5) * 0.18 * glitchStrength * midBoost; + float edgeWidth = 0.09 + 0.03 * (1.0 - midBoost); + float mask = smoothstep(edgeBase - edgeWidth, edgeBase + edgeWidth, vUv.x); + + vec3 mixedRgb = mix(colA, colB, mask); + + float glow = exp(-abs(vUv.x - edgeBase) * 140.0) * 0.22 * glitchStrength * midBoost; + mixedRgb = clamp(mixedRgb + edgeColor * glow, 0.0, 1.0); + + float alpha = mix(texel1.a, texel2.a, mask); + return vec4(mixedRgb, alpha); +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681221330687020295/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681221330687020295/AmazingFeature/xshader/Unlit.frag b/scripts/7681221330687020295/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681221330687020295/AmazingFeature/xshader/Unlit.vert b/scripts/7681221330687020295/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681221330687020295/AmazingFeature/xshader/noface.frag b/scripts/7681221330687020295/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681221330687020295/AmazingFeature/xshader/noface.vert b/scripts/7681221330687020295/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681221330687020295/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681221330687020295/config.json b/scripts/7681221330687020295/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681221330687020295/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681221330687020295/extra.json b/scripts/7681221330687020295/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..47e6ac7fa3888edae13cecf1e8408ca3c70d4433 --- /dev/null +++ b/scripts/7681221330687020295/extra.json @@ -0,0 +1,53 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "\u6548\u679c\u8fdb\u5ea6", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "glitchStrength", + "effect_key_cn": "glitch", + "type": "float", + "default": 0.65, + "min": 0, + "max": 1 + }, + { + "effect_key": "chromaAmount", + "effect_key_cn": "chroma", + "type": "float", + "default": 0.45, + "min": 0, + "max": 1 + }, + { + "effect_key": "gridScale", + "effect_key_cn": "grid S", + "type": "float", + "default": 36, + "min": 8, + "max": 120 + }, + { + "effect_key": "edgeColor", + "effect_key_cn": "edge C", + "type": "color", + "default": [ + 0, + 1, + 0.9 + ] + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681226179084389652/AmazingFeature/content.json b/scripts/7681226179084389652/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..e0ecff357e1e0538b40157ccaef780bd6d922650 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,388 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_102-effect0', 'InputTex', 0}, + {'LumiSGlow_103-effect0', 'InputTex', 1}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_102-effect0'] = { + ['nodeDuration'] = {{0, 1.56666666666667}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.56666666666667}, }, + }, + }, + ['LumiGaussianBlur_102-effect1'] = { + ['nodeDuration'] = {{0, 1.56666666666667}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.56666666666667}, }, + }, + }, + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.56666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.56666666666667, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.56666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.56666666666667, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.56666666666667}, }, + ['baseTex'] = {{1.56666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_102-effect0'] = { + ['brightness'] = 0, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_102-effect1'] = { + ['blurIntensity'] = 0, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 0, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_102-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.333333, 1.566667, }, + {{0, }, {10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_102-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.333333, 1.566667, }, + {{0, }, {30, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.566667, 1.866667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.566667, 1.866667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681226179084389652/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681226179084389652/config.json b/scripts/7681226179084389652/config.json new file mode 100644 index 0000000000000000000000000000000000000000..9f31af422865e2aec2b17ffdc4b9404f5d5b7990 --- /dev/null +++ b/scripts/7681226179084389652/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903183421678", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681226179084389652/extra.json b/scripts/7681226179084389652/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681226179084389652/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681238133245005076/AmazingFeature/content.json b/scripts/7681238133245005076/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..68ef60420305ebbaba3f0663fee4b3e3d57e1862 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,323 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_103-effect0', 'InputTex', 1}, + {'LumiLayer_102-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.66666666666667}, }, + ['baseTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681238133245005076/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681238133245005076/config.json b/scripts/7681238133245005076/config.json new file mode 100644 index 0000000000000000000000000000000000000000..067d981852e95ab507ef8a809b30f6635a5b0029 --- /dev/null +++ b/scripts/7681238133245005076/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903182339455", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681238133245005076/extra.json b/scripts/7681238133245005076/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681238133245005076/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681243554273905941/AmazingFeature/content.json b/scripts/7681243554273905941/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..5a2fd0583545d8fa4ff20c7675bd890b264e5f2c --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,323 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_103-effect0', 'InputTex', 1}, + {'LumiLayer_102-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.66666666666667}, }, + ['baseTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 3.1640625082003, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 9.49218752460089, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681243554273905941/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681243554273905941/config.json b/scripts/7681243554273905941/config.json new file mode 100644 index 0000000000000000000000000000000000000000..1d8d28aa9d98a37a1cd51a8d976278133202dcac --- /dev/null +++ b/scripts/7681243554273905941/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903180126040", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681243554273905941/extra.json b/scripts/7681243554273905941/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681243554273905941/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681252890261867796/AmazingFeature/content.json b/scripts/7681252890261867796/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..2cf18c106daf40d1ab9872453e9d2a5805826de3 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,323 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_103-effect0', 'InputTex', 1}, + {'LumiLayer_102-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.53333333333333, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.53333333333333, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.53333333333333, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.53333333333333, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.53333333333333}, }, + ['baseTex'] = {{1.53333333333333, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681252890261867796/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681252890261867796/config.json b/scripts/7681252890261867796/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a1cc9de884a5b5bcd5ac0acad75684455d5c773b --- /dev/null +++ b/scripts/7681252890261867796/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903182532649", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681252890261867796/extra.json b/scripts/7681252890261867796/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681252890261867796/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681253125172251925/AmazingFeature/content.json b/scripts/7681253125172251925/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..832501f4a442a5b9f156a10b9792ac4950f9fab0 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,323 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_103-effect0', 'InputTex', 1}, + {'LumiLayer_102-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{0.9, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.9, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{0.9, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.9, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 0.9}, }, + ['baseTex'] = {{0.9, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 0, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.9, 1.333333, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.9, 1.333333, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681253125172251925/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681253125172251925/config.json b/scripts/7681253125172251925/config.json new file mode 100644 index 0000000000000000000000000000000000000000..2c87af04dc8e37c45f357e98bcf6b91b557669e6 --- /dev/null +++ b/scripts/7681253125172251925/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903182746173", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681253125172251925/extra.json b/scripts/7681253125172251925/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681253125172251925/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681254982942919957/AmazingFeature/content.json b/scripts/7681254982942919957/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..9859fe33b4acf82e3a72cb39f53534b88c3f2f99 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,388 @@ +local data = {} + +local ae_compDurations = {0.03333333333333, 2.03333333333333} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_102-effect0', 'InputTex', 0}, + {'LumiSGlow_103-effect0', 'InputTex', 1}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_102-effect0'] = { + ['nodeDuration'] = {{0, 1.56666666666667}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.56666666666667}, }, + }, + }, + ['LumiGaussianBlur_102-effect1'] = { + ['nodeDuration'] = {{0, 1.56666666666667}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.56666666666667}, }, + }, + }, + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.56666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.56666666666667, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.56666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.56666666666667, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.56666666666667}, }, + ['baseTex'] = {{1.56666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_102-effect0'] = { + ['brightness'] = 0, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_102-effect1'] = { + ['blurIntensity'] = 0, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 100, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_102-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.333333, 1.566667, }, + {{0, }, {10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_102-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.333333, 1.566667, }, + {{0, }, {30, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.566667, 1.866667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.566667, 1.866667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681254982942919957/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681254982942919957/config.json b/scripts/7681254982942919957/config.json new file mode 100644 index 0000000000000000000000000000000000000000..3bd0a4cb43e4317ab52bbcba2e87b5842e8a2ac1 --- /dev/null +++ b/scripts/7681254982942919957/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903184103197", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681254982942919957/extra.json b/scripts/7681254982942919957/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681254982942919957/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681255409583181077/AmazingFeature/content.json b/scripts/7681255409583181077/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..9c774c5c166d245ee767c7e4e4b2a533c9492be3 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,323 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_103-effect0', 'InputTex', 1}, + {'LumiLayer_102-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.66666666666667}, }, + ['baseTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 0, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681255409583181077/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681255409583181077/config.json b/scripts/7681255409583181077/config.json new file mode 100644 index 0000000000000000000000000000000000000000..6374e3fd694d74f5005911d4180d8627132e2042 --- /dev/null +++ b/scripts/7681255409583181077/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903182201718", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681255409583181077/extra.json b/scripts/7681255409583181077/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681255409583181077/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681256151412919572/AmazingFeature/content.json b/scripts/7681256151412919572/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..9c774c5c166d245ee767c7e4e4b2a533c9492be3 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,323 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_103-effect0', 'InputTex', 1}, + {'LumiLayer_102-blend', 'InputTex', 0}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{1.66666666666667, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 1.66666666666667}, }, + ['baseTex'] = {{1.66666666666667, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 0, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {1.7, 1.966667, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681256151412919572/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681256151412919572/config.json b/scripts/7681256151412919572/config.json new file mode 100644 index 0000000000000000000000000000000000000000..3864dd9fd876b4a804991b4db57a4b0aa46dec5b --- /dev/null +++ b/scripts/7681256151412919572/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903181539368", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681256151412919572/extra.json b/scripts/7681256151412919572/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681256151412919572/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681256417281527061/AmazingFeature/content.json b/scripts/7681256417281527061/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..91fbb9be9167ba1f5315de330b0f1903d08afc0b --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_96763024926065909023875386850577846442", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua new file mode 100644 index 0000000000000000000000000000000000000000..ad89ef9e556344298c5640f5c9bc5076919a0c37 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/lua/LumiAnimSeqLoadAndCrop.lua @@ -0,0 +1,319 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop or {} +LumiAnimSeqLoadAndCrop.__index = LumiAnimSeqLoadAndCrop +---@class LumiAnimSeqLoadAndCrop : ScriptComponent +---@field animSeqType string [UI(Option={"Video", "Image", "Texture"})] +---@field cropType string [UI(Option={"Stretch", "Fill", "Fit", "Texture Size"})] +---@field edgeType string [UI(Option={"Tile", "Mirror", "Clamp", "Empty"})] +---@field pivot Vector2f +---@field position Vector2f +---@field rotation double [UI(Range={0, 360}, Drag)] +---@field scale double [UI(Range={0, 5}, Drag)] +---@field opacity double [UI(Range={0, 1}, Drag)] +---@field playMode string [UI(Option={"once", "loop"})] +---@field speed double [UI(Range={0.001, 10}, Drag)] +---@field seqTime number [UI(Range={0, 100}, Drag)] +---@field enableVideoAlphaBlend boolean +---@field videoFilename String +---@field animSeq AnimSeq +---@field seqTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local animSeqTypeName = { + "Video", "Image", "Texture", +} +setmetatable(animSeqTypeName, {__index = function(_, _) return animSeqTypeName[1] end}) +local animSeqTypeIndex = {} +for index, value in ipairs(animSeqTypeName) do animSeqTypeIndex[value] = index - 1 end +setmetatable(animSeqTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, 'Unsupported AnimSeqType: ' .. key) + return 0 + end +}) + +local cropTypeName = { + "Stretch", "Fill", "Fit", "Texture Size" +} +setmetatable(cropTypeName, {__index = function(_, _) return cropTypeName[1] end}) +local cropTypeIndex = {} +for index, value in ipairs(cropTypeName) do cropTypeIndex[value] = index - 1 end +setmetatable(cropTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported SeqCrop Type: " .. key) + return 0 + end +}) + +local edgeTypeName = { + "Tile", "Mirror", "Clamp", "Empty", +} +setmetatable(edgeTypeName, {__index = function(_, _) return edgeTypeName[1] end}) +local edgeTypeIndex = {} +for index, value in ipairs(edgeTypeName) do edgeTypeIndex[value] = index - 1 end +setmetatable(edgeTypeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Edge Type: " .. key) + return 0 + end +}) + +local playModeName = { + "once", "loop" +} +setmetatable(playModeName, {__index = function(_, _) return playModeName[1] end}) +local playModeIndex = {} +for index, value in ipairs(playModeName) do playModeIndex[value] = index - 1 end +setmetatable(playModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported Play Mode: " .. key) + return 0 + end +}) + +function LumiAnimSeqLoadAndCrop.new(construct, ...) + local self = setmetatable({}, LumiAnimSeqLoadAndCrop) + + self.AEPlugin = false + self.seqTime = 0.0 + self.globalRotation = 0.0 + self.globalScale = 1.0 + self.globalOpacity = 1.0 + self.globalSpeed = 1.0 + + self.paramInitInfo = { + {'specify', false}, + {'animSeqType', 'Texture'}, + {'cropType', 'Stretch'}, + {'edgeType', 'Empty'}, + {'pivot', Amaz.Vector2f(0.5, 0.5)}, + {'position', Amaz.Vector2f(0.5, 0.5)}, + {'rotation', 0}, + {'scale', 1.0}, + {'opacity', 1.0}, + {'playMode', 'loop'}, + {'speed', 1.0}, + -- Video seq + {'videoFilename', ''}, + {'enableVideoAlphaBlend', false}, + -- Image seq + {'animSeq', nil}, + -- Texture + {'seqTex', nil}, + } + + self.multiAspect = { + ['5.8'] = 1.125 / 2.436, -- 0.4618 + ['9_16'] = 9 / 16, -- 0.5625 + ['3_4'] = 3 / 4, -- 0.75 + ['1_1'] = 1, + ['4_3'] = 4 / 3, -- 1.3333 + ['16_9'] = 16 / 9, -- 1.7778 + ['1.85_1'] = 1.85, + ['2_1'] = 2, + ['2.35_1'] = 2.35, + } + + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + + for key, _ in pairs(self.multiAspect) do + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1] .. '_' .. key] = self.paramInitInfo[i][2] + end + end + + self.needUpdateSize = true + self.InputTex = nil + self.OutputTex = nil + + return self +end + +function LumiAnimSeqLoadAndCrop:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.camera = self.entity:searchEntity("AnimSeqCamera"):getComponent("Camera") + self.material = self.entity:searchEntity('AnimSeqPass'):getComponent('MeshRenderer').material + self.videoAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("VideoAnimSeq") + self.seqAnim = self.entity:searchEntity("AnimSeqPass"):getComponent("AnimSeqComponent") +end + +function LumiAnimSeqLoadAndCrop:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _force) + if _force or self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if self[key] ~= nil then + if key:sub(1, #'cropType') == 'cropType' then + local type = cropTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'edgeType') == 'edgeType' then + local type = edgeTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'animSeqType') == 'animSeqType' then + local type = animSeqTypeName[value + 1] + _setEffectAttr(key, type) + elseif key:sub(1, #'playMode') == 'playMode' then + local type = playModeName[value + 1] + _setEffectAttr(key, type) + else + _setEffectAttr(key, value) + end + elseif key:sub(1, #'seqTex') == 'seqTex' + or key:sub(1, #'animSeq') == 'animSeq' + then + _setEffectAttr(key, value, true) + else + _setEffectAttr(key, value) + end +end + +function LumiAnimSeqLoadAndCrop:afterAnimSeqSystemUpdate(comp) + if self.animSeqType == "Image" then + if self.needUpdateSize and self.material then + local seqTex = self.material:getTex("u_seqTexture") + self.material:setVec2("u_seqTexSize", Amaz.Vector2f(seqTex.width, seqTex.height)) + seqTex = nil + self.needUpdateSize = false + end + end +end + +function LumiAnimSeqLoadAndCrop:onUpdate(comp, deltaTime) + if self.OutputTex then + self.camera.renderTexture = self.OutputTex + end + + local w = self.camera.renderTexture.width + local h = self.camera.renderTexture.height + + local ratio = w / h + local paramFlag = '' + local _diff = math.huge + for key, value in pairs(self.multiAspect) do + if self['specify_' .. key] then + local diff = math.abs(ratio - value) + if diff < _diff then + _diff = diff + paramFlag = key + end + end + end + + -- update parameters based on resolution + if paramFlag == '' then + if self.AEPlugin then + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio .. ', reset params!') + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self.paramInitInfo[i][2] + end + else + Amaz.LOGE(self.TAG, 'No aspect specified' .. ', ratio: ' .. ratio) + end + else + for i = 1, #self.paramInitInfo do + self[self.paramInitInfo[i][1]] = self[self.paramInitInfo[i][1] .. '_' .. paramFlag] + end + end + + if self.AEPlugin then + self.animSeqType = 'Texture' + end + + self.material:setTex("u_inputTexture", self.InputTex) + self.material:setInt('u_cropType', cropTypeIndex[self.cropType]) + self.material:setInt('u_edgeType', edgeTypeIndex[self.edgeType]) + self.material:setFloat('u_opacity', self.opacity * self.globalOpacity) + self.material:setVec2('u_scale', Amaz.Vector2f(self.scale, self.scale) * self.globalScale) + self.material:setVec2('u_pivot', self.pivot - Amaz.Vector2f(0.5, 0.5)) + self.material:setVec2('u_position', self.position - Amaz.Vector2f(0.5, 0.5)) + self.material:setFloat('u_rotation', math.rad(self.rotation + self.globalRotation)) + + local playMode = Amaz.PlayMode.loop + if self.playMode == 'once' then + playMode = Amaz.PlayMode.once + end + + local speed = self.speed * self.globalSpeed + + if self.animSeqType == "Video" then + self.videoAnim.enabled = true + self.seqAnim.enabled = false + + if not isEditor then + self.videoAnim.enableFixedSeekMode = true + end + if self.videoAnim.videoFilename ~= self.videoFilename then + self.videoAnim.videoFilename = self.videoFilename + end + if self.videoAnim.enableAlphaBlend ~= self.enableVideoAlphaBlend then + self.videoAnim.enableAlphaBlend = self.enableVideoAlphaBlend + end + if self.videoAnim.playmode ~= playMode then + self.videoAnim.playmode = playMode + end + if self.videoAnim.speed ~= speed then + self.videoAnim.speed = speed + end + local frames = self.videoAnim:getFrameCount() + local duration = self.videoAnim:getDuration() + local videoFps = frames / duration * 1000 + self.videoAnim:seekToTime(self.seqTime + 0.5 / videoFps) + local videoSize = self.videoAnim:getVideoSize() + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", 0) + -- self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Image" then + self.videoAnim.enabled = false + self.seqAnim.enabled = true + + if self.seqAnim.animSeq ~= self.animSeq then + self.seqAnim.animSeq = self.animSeq + self.needUpdateSize = true + end + if self.seqAnim.playmode ~= playMode then + self.seqAnim.playmode = playMode + end + if self.seqAnim.speed ~= speed then + self.seqAnim.speed = speed + end + self.seqAnim:seekToTime(self.seqTime + 0.5 / self.animSeq.fps) + self.material:setInt("u_convertAlpha", 0) + self.material:setInt('u_yFlip', 1) + elseif self.animSeqType == "Texture" then + self.videoAnim.enabled = false + self.seqAnim.enabled = false + + if self.seqTex then + self.material:setTex("u_seqTexture", self.seqTex) + local videoSize = Amaz.Vector2f(self.seqTex.width, self.seqTex.height) + if self.enableVideoAlphaBlend then + videoSize.x = videoSize.x / 2 + end + self.material:setVec2("u_seqTexSize", videoSize) + self.material:setInt("u_convertAlpha", self.enableVideoAlphaBlend and 1 or 0) + else + self.material:setVec2('u_scale', Amaz.Vector2f(0, 0)) + end + self.material:setInt('u_yFlip', 0) + end +end + +exports.LumiAnimSeqLoadAndCrop = LumiAnimSeqLoadAndCrop +return exports diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..776d48b9649c5f359d8b806bfa1895121567e7d5 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,162 @@ +precision highp float; +precision highp int; + +uniform mediump int u_yFlip; +uniform mediump int u_convertAlpha; +uniform mediump sampler2D u_seqTexture; +uniform vec4 u_ScreenParams; +uniform vec2 u_scale; +uniform float u_rotation; +uniform vec2 u_position; +uniform vec2 u_pivot; +uniform vec2 u_seqTexSize; +uniform mediump int u_cropType; +uniform mediump int u_edgeType; +uniform float u_opacity; + +varying vec2 uv0; + +vec2 _f4(inout vec2 _p0, float _p1, vec2 _p2, vec2 _p3, vec2 _p4) +{ + _p0 -= _p2; + _p0 -= vec2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = mat2(vec2(_172, _169), vec2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += vec2(0.5); + _p0 += _p3; + return _p0; +} + +vec2 _f2(vec2 _p0) +{ + vec2 _122 = mod(_p0, vec2(1.0)); + return _122 + (vec2(1.0) - step(vec2(0.0), _122)); +} + +vec2 _f1(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +vec4 _f0(inout vec2 _p0) +{ + if (u_yFlip == 1) + { + _p0 = vec2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return texture2D(u_seqTexture, _p0); + } + vec4 _t2; + _t2.w = texture2D(u_seqTexture, vec2(_p0.x * 0.5, _p0.y)).x; + mediump vec3 _97 = texture2D(u_seqTexture, vec2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +float _f3(vec2 _p0) +{ + vec2 _t4 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t4.x * _t4.y; +} + +void main() +{ + bool _214 = abs(u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + gl_FragData[0] = vec4(0.0); + return; + } + vec2 param = uv0; + float param_1 = u_rotation; + vec2 param_2 = u_position; + vec2 param_3 = u_pivot; + vec2 param_4 = u_scale; + vec2 _245 = _f4(param, param_1, param_2, param_3, param_4); + vec2 _t8 = _245; + float _252 = u_seqTexSize.x / u_seqTexSize.y; + float _258 = u_ScreenParams.x / u_ScreenParams.y; + vec2 _t11 = _245; + if (u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (u_cropType == 3) + { + _t11 -= vec2(0.5); + _t11.x *= (u_ScreenParams.x / u_seqTexSize.x); + _t11.y *= (u_ScreenParams.y / u_seqTexSize.y); + _t11 += vec2(0.5); + } + } + } + if (u_edgeType == 0) + { + vec2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (u_edgeType == 1) + { + vec2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + vec2 param_7 = _t11; + vec4 _389 = _f0(param_7); + vec4 _t16 = _389; + if (u_edgeType == 3) + { + vec2 param_8 = _t11; + _t16 *= _f3(param_8); + } + vec4 _401 = _t16; + vec4 _402 = _401 * u_opacity; + _t16 = _402; + gl_FragData[0] = _402; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderGLES/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag new file mode 100644 index 0000000000000000000000000000000000000000..d21575c9d17e191328bff9c1ab15dd22db3dc969 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.frag @@ -0,0 +1,190 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_yFlip; + int u_convertAlpha; + float4 u_ScreenParams; + float2 u_scale; + float u_rotation; + float2 u_position; + float2 u_pivot; + float2 u_seqTexSize; + int u_cropType; + int u_edgeType; + float u_opacity; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f4(thread float2& _p0, thread const float& _p1, thread const float2& _p2, thread const float2& _p3, thread const float2& _p4, constant float4& u_ScreenParams) +{ + _p0 -= _p2; + _p0 -= float2(0.5); + _p0.y *= (u_ScreenParams.y / u_ScreenParams.x); + float _169 = sin(_p1); + float _172 = cos(_p1); + _p0 = float2x2(float2(_172, _169), float2(-_169, _172)) * _p0; + _p0.y *= (u_ScreenParams.x / u_ScreenParams.y); + _p0 /= _p4; + _p0 += float2(0.5); + _p0 += _p3; + return _p0; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float2& _p0) +{ + float2 _122 = mod(_p0, float2(1.0)); + return _122 + (float2(1.0) - step(float2(0.0), _122)); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float4 _f0(thread float2& _p0, constant int& u_yFlip, constant int& u_convertAlpha, texture2d u_seqTexture, sampler u_seqTextureSmplr) +{ + if (u_yFlip == 1) + { + _p0 = float2(_p0.x, 1.0 - _p0.y); + } + if (u_convertAlpha == 0) + { + return u_seqTexture.sample(u_seqTextureSmplr, _p0); + } + float4 _t2; + _t2.w = u_seqTexture.sample(u_seqTextureSmplr, float2(_p0.x * 0.5, _p0.y)).x; + float3 _97 = u_seqTexture.sample(u_seqTextureSmplr, float2((_p0.x * 0.5) + 0.5, _p0.y)).xyz; + _t2.x = _97.x; + _t2.y = _97.y; + _t2.z = _97.z; + return _t2; +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t4 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t4.x * _t4.y; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_seqTexture [[texture(0)]], sampler u_seqTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + bool _214 = abs(buffer.u_scale.x) < 9.9999997473787516355514526367188e-05; + bool _222; + if (!_214) + { + _222 = abs(buffer.u_scale.y) < 9.9999997473787516355514526367188e-05; + } + else + { + _222 = _214; + } + if (_222) + { + out.o_fragColor = float4(0.0); + return out; + } + float2 param = in.uv0; + float param_1 = buffer.u_rotation; + float2 param_2 = buffer.u_position; + float2 param_3 = buffer.u_pivot; + float2 param_4 = buffer.u_scale; + float2 _245 = _f4(param, param_1, param_2, param_3, param_4, buffer.u_ScreenParams); + float2 _t8 = _245; + float _252 = buffer.u_seqTexSize.x / buffer.u_seqTexSize.y; + float _258 = buffer.u_ScreenParams.x / buffer.u_ScreenParams.y; + float2 _t11 = _245; + if (buffer.u_cropType == 1) + { + if (_252 > _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 2) + { + if (_252 < _258) + { + _t11.y = _t8.y; + _t11.x = ((_t8.x - 0.5) * (_258 / _252)) + 0.5; + } + else + { + _t11.x = _t8.x; + _t11.y = ((_t8.y - 0.5) * (_252 / _258)) + 0.5; + } + } + else + { + if (buffer.u_cropType == 3) + { + _t11 -= float2(0.5); + _t11.x *= (buffer.u_ScreenParams.x / buffer.u_seqTexSize.x); + _t11.y *= (buffer.u_ScreenParams.y / buffer.u_seqTexSize.y); + _t11 += float2(0.5); + } + } + } + if (buffer.u_edgeType == 0) + { + float2 param_5 = _t11; + _t11 = _f2(param_5); + } + else + { + if (buffer.u_edgeType == 1) + { + float2 param_6 = _t11; + _t11 = _f1(param_6); + } + } + float2 param_7 = _t11; + float4 _389 = _f0(param_7, buffer.u_yFlip, buffer.u_convertAlpha, u_seqTexture, u_seqTextureSmplr); + float4 _t16 = _389; + if (buffer.u_edgeType == 3) + { + float2 param_8 = _t11; + _t16 *= _f3(param_8); + } + float4 _401 = _t16; + float4 _402 = _401 * buffer.u_opacity; + _t16 = _402; + out.o_fragColor = _402; + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiAnimSeqLoadAndCrop/xshader/shaderLib/shaderMetal/eade43c2f1bac03288c074b3071433fe.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua new file mode 100644 index 0000000000000000000000000000000000000000..091b686d297b5b35a8a65c07b9825864f1b2b8d6 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/lua/ScriptCompGaussianBlur.lua @@ -0,0 +1,309 @@ +---@class ScriptCompGaussianBlur: ScriptComponent +---@field blurIntensity number [UI(Range={0., 1000.}, Drag)] +---@field horizontalStrength number [UI(Range={0., 1.}, Drag)] +---@field verticalStrength number [UI(Range={0., 1.}, Drag)] +---@field quality number [UI(Range={0., 1.}, Drag)] +---@field spaceDither number [UI(Range={0, 1.}, Drag)] +---@field blurDirection string [UI(Option={"Horizontal and Vertical", "Horizontal", "Vertical"})] +---@field borderType string [UI(Option={"Normal", "Replicate", "Black", "Reflect"})] +---@field blurAlpha boolean +---@field inverseGammaCorrection boolean +---@field InputTex Texture +---@field OutputTex Texture +---@field downsampleXTex Texture +---@field downsampleYTex Texture +---@field downsampleRT Vector [UI(Type="Texture")] + +local exports = exports or {} +local ScriptCompGaussianBlur = ScriptCompGaussianBlur or {} +ScriptCompGaussianBlur.__index = ScriptCompGaussianBlur + +------------ util functions ------------ +local function clamp(value, min, max) + --[[ + Description: clamp value between [min, max] + ]] + return math.min(math.max(value, min), max) +end + +local function getXYScale(width, height) + --[[ + Description: get XY scale for adjusting width/height ratio. + ]] + -- the following computation for baseSize is to avoid too small or too large width/height ratio. + local size1 = math.min(width, height) + local size2 = math.max(width, height) / 2. + local baseSize = math.max(size1, size2) + + local xScale = baseSize / width + local yScale = baseSize / height + return xScale, yScale +end + +local function boolToInt(flag) + --[[ + Description: convert flag from bool to int + ]] + if flag then return 1 end + return 0 +end + +local function getBorderType(borderType) + --[[ + Description: convert borderType from string to int + ]] + local borderTypeTable = { + ["Normal"] = 0, -- default + ["Replicate"] = 1, + ["Black"] = 2, + ["Reflect"] = 3 + } + local flag = borderTypeTable[borderType] + if flag == nil then flag = 0 end + return flag +end + +local function getSampleNum(intensity) + --[[ + Description: get sample number and downsample scale + ]] + local scale = 1. + local bias = 0. + local s = scale + if intensity <= 30 then + scale = 0.5 + bias = 2. + s = 0.78 + elseif intensity <= 100 then + scale = 0.5 + bias = 10 + s = 0.66 + elseif intensity <= 200 then + scale = 0.25 + bias = 50. + s = 0.7 + else + scale = 0.125 + bias = 80. + s = 0.8 + end + + local sampleNum = scale * intensity + bias + sampleNum = sampleNum * s + if sampleNum < 2. then + sampleNum = math.floor(sampleNum + 0.5) + end + return sampleNum, scale +end + +local function getQualityParam(quality) + local qualityParam = quality * 2. - 1. + if qualityParam < 0. then + qualityParam = 10 ^ qualityParam + else + qualityParam = qualityParam * 2. + 1. + end + return qualityParam +end + +------------ class functions for ScriptComponent ------------ +function ScriptCompGaussianBlur.new(construct, ...) + local self = setmetatable({}, ScriptCompGaussianBlur) + + if construct and ScriptCompGaussianBlur.constructor then ScriptCompGaussianBlur.constructor(self, ...) end + -- user parameters + self.blurIntensity = 0. + self.horizontalStrength = 1. + self.verticalStrength = 1. + self.quality = 0.5 + self.blurDirection = "Horizontal and Vertical" + self.borderType = "Normal" + self.blurAlpha = true + self.inverseGammaCorrection = true + self.spaceDither = 0. + + -- other parameters + self.NormalizationSize = 1000. + self.MaxIntensity = 1000. + self.RadiusOverSigma = 2.5 + self.Gamma = 2.2 + self.Eps = 1e-5 + + self.InputTex = nil + self.OutputTex = nil + return self +end + +function ScriptCompGaussianBlur:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value, _comp) + if self[_key] ~= nil then + self[_key] = _value + if _comp and _comp.properties ~= nil then + _comp.properties:set(_key, _value) + end + end + end + + if key == "blurDirection" then + local typeTable = { + [0] = "Horizontal and Vertical", + [1] = "Horizontal", + [2] = "Vertical" + } + local blurDirection = typeTable[value] + if blurDirection == nil then blurDirection = "Horizontal and Vertical" end + _setEffectAttr(key, blurDirection, comp) + elseif key == "borderType" then + local typeTable = { + [0] = "Normal", + [1] = "Replicate", + [2] = "Black", + [3] = "Reflect" + } + local borderType = typeTable[value] + if borderType == nil then borderType = "Normal" end + _setEffectAttr(key, borderType, comp) + else + _setEffectAttr(key, value, comp) + end +end + +function ScriptCompGaussianBlur:onStart(comp) + self.camGaussianBlurX = comp.entity:searchEntity("CameraGaussianBlurX"):getComponent("Camera") + self.camGaussianBlurY = comp.entity:searchEntity("CameraGaussianBlurY"):getComponent("Camera") + self.camDownScale = comp.entity:searchEntity("CameraDownScale"):getComponent("Camera") + self.camUpScale = comp.entity:searchEntity("CameraUpScale"):getComponent("Camera") + + self.matGaussianBlurX = comp.entity:searchEntity("EntityGaussianBlurX"):getComponent("MeshRenderer").material + self.matGaussianBlurY = comp.entity:searchEntity("EntityGaussianBlurY"):getComponent("MeshRenderer").material +end + +function ScriptCompGaussianBlur:updateDownsampleRT(textureWidth, textureHeight, downScale) + local x2= self.downsampleRT:get(0) + local y2= self.downsampleRT:get(1) + local x4= self.downsampleRT:get(2) + local y4= self.downsampleRT:get(3) + local x8= self.downsampleRT:get(4) + local y8= self.downsampleRT:get(5) + x2.width = textureWidth / 2 + x2.height = textureHeight / 2 + y2.width = textureWidth / 2 + y2.height = textureHeight / 2 + x4.width = textureWidth / 4 + x4.height = textureHeight / 4 + y4.width = textureWidth / 4 + y4.height = textureHeight / 4 + x8.width = textureWidth / 8 + x8.height = textureHeight / 8 + y8.width = textureWidth / 8 + y8.height = textureHeight / 8 + if downScale <= 0.125 + self.Eps then + self.downsampleXTex = x8 + self.downsampleYTex = y8 + elseif downScale <= 0.25 + self.Eps then + self.downsampleXTex = x4 + self.downsampleYTex = y4 + else + self.downsampleXTex = x2 + self.downsampleYTex = y2 + end +end + +function ScriptCompGaussianBlur:onUpdate(comp, deltaTime) + local textureWidth = self.OutputTex.width + local textureHeight = self.OutputTex.height + + -- compute intensity. intensityX/Y are the only factors that affect blur intensity + self.blurIntensity = clamp(self.blurIntensity, 0., self.MaxIntensity) + self.horizontalStrength = clamp(self.horizontalStrength, 0., 1.) + self.verticalStrength = clamp(self.verticalStrength, 0., 1.) + local xStrenth = self.horizontalStrength + local yStrenth = self.verticalStrength + if self.blurDirection == "Horizontal" then + yStrenth = 0. + elseif self.blurDirection == "Vertical" then + xStrenth = 0. + end + local intensityX = self.blurIntensity * xStrenth + local intensityY = self.blurIntensity * yStrenth + local sampleNum, downScale = getSampleNum(self.blurIntensity) + self.quality = clamp(self.quality, 0., 1.) + local qualityParam = getQualityParam(self.quality) + local borderType = getBorderType(self.borderType) + local inverseGammaCorrection = boolToInt(self.inverseGammaCorrection) + local blurAlpha = boolToInt(self.blurAlpha) + self.spaceDither = clamp(self.spaceDither, 0., 1.) + + self:updateDownsampleRT(textureWidth, textureHeight, downScale) + + -- compute sigmaX/Y, sampleX/Y, dx/y. + local xScale, yScale = getXYScale(textureWidth, textureHeight) + local radiusX = xScale * intensityX / self.NormalizationSize + local radiusY = yScale * intensityY / self.NormalizationSize + local sigmaX = radiusX / self.RadiusOverSigma + local sigmaY = radiusY / self.RadiusOverSigma + local sampleX = sampleNum * self.horizontalStrength * qualityParam + local sampleY = sampleNum * self.verticalStrength * qualityParam + local dx = radiusX / math.max(sampleX, self.Eps) + local dy = radiusY / math.max(sampleY, self.Eps) + + -- set Textures + self.camDownScale.inputTexture = self.InputTex + self.camDownScale.renderTexture = self.downsampleYTex + self.camUpScale.renderTexture = self.OutputTex + if self.blurIntensity <= 0.01 then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = false + self.camUpScale.inputTexture = self.InputTex + elseif self.blurDirection == "Horizontal" then + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = false + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + elseif self.blurDirection == "Vertical" then + self.camGaussianBlurX.entity.visible = false + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.camDownScale.renderTexture = self.downsampleYTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurY.renderTexture = self.downsampleXTex + self.camUpScale.inputTexture = self.downsampleXTex + else + self.camGaussianBlurX.entity.visible = true + self.camGaussianBlurY.entity.visible = true + self.camDownScale.entity.visible = true + self.matGaussianBlurX:setTex("u_inputTexture", self.downsampleYTex) + self.camGaussianBlurX.renderTexture = self.downsampleXTex + self.matGaussianBlurY:setTex("u_inputTexture", self.downsampleXTex) + self.camGaussianBlurY.renderTexture = self.downsampleYTex + self.camUpScale.inputTexture = self.downsampleYTex + end + + -- set parameters for materials + self.matGaussianBlurX:setFloat("u_sampleX", sampleX) + self.matGaussianBlurX:setFloat("u_sigmaX", sigmaX) + self.matGaussianBlurX:setFloat("u_stepX", dx) + self.matGaussianBlurX:setFloat("u_stepY", dy) + self.matGaussianBlurX:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurX:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurX:setInt("u_borderType", borderType) + self.matGaussianBlurX:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurX:setInt("u_blurAlpha", blurAlpha) + + self.matGaussianBlurY:setFloat("u_sampleY", sampleY) + self.matGaussianBlurY:setFloat("u_sigmaY", sigmaY) + self.matGaussianBlurY:setFloat("u_stepX", dx) + self.matGaussianBlurY:setFloat("u_stepY", dy) + self.matGaussianBlurY:setFloat("u_gamma", self.Gamma) + self.matGaussianBlurY:setFloat("u_spaceDither", self.spaceDither) + self.matGaussianBlurY:setInt("u_borderType", borderType) + self.matGaussianBlurY:setInt("u_inverseGammaCorrection", inverseGammaCorrection) + self.matGaussianBlurY:setInt("u_blurAlpha", blurAlpha) +end + +exports.ScriptCompGaussianBlur = ScriptCompGaussianBlur +return exports diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..f490c140cc1b7a1b98ec3d159b8a3bad31563edd --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleY; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaY; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _108 = _t3; + vec3 _114 = pow(_108.xyz, vec3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _49 = fract(vec3(((_p0 * u_ScreenParams.xy) + vec2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + vec3 _t1 = _49 + vec3(dot(_49, _49.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleY < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _142 = _f2(u_inputTexture, param); + vec4 _t4 = _142; + float param_1 = 0.0; + float param_2 = u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + vec4 _t6 = _142 * _149; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _190 = float(_t10); + if (_190 > u_sampleY) + { + break; + } + float _200 = _190 * u_stepY; + float param_4 = _200; + float param_5 = u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (u_borderType == 1) + { + _t9.y = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = -_t9.y; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (u_borderType == 1) + { + _t9.y = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _206); + _t5 += _206; + } + else + { + if (u_borderType == 2) + { + _t5 += _206; + } + else + { + if (u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _206); + _t5 += _206; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _206); + _t5 += _206; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _346 = _t6; + vec3 _351 = pow(_346.xyz, vec3(1.0 / u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..f63bd1c0322635fdd9f4cc073cbc7c22e6084cc7 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,161 @@ +precision highp float; +precision highp int; + +uniform vec4 u_ScreenParams; +uniform mediump int u_inverseGammaCorrection; +uniform float u_gamma; +uniform float u_sampleX; +uniform mediump sampler2D u_inputTexture; +uniform float u_sigmaX; +uniform float u_spaceDither; +uniform float u_stepX; +uniform float u_stepY; +uniform mediump int u_borderType; +uniform mediump int u_blurAlpha; + +varying vec2 v_uv; + +vec4 _f2(mediump sampler2D _p0, vec2 _p1) +{ + vec4 _t3 = texture2D(_p0, _p1); + if (u_inverseGammaCorrection == 1) + { + vec4 _105 = _t3; + vec3 _111 = pow(_105.xyz, vec3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +float _f1(float _p0, float _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +float _f0(vec2 _p0) +{ + vec3 _46 = fract(vec3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + vec3 _t1 = _46 + vec3(dot(_46, _46.yzx + vec3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +void main() +{ + if (u_sampleX < 9.9999997473787516355514526367188e-06) + { + gl_FragData[0] = texture2D(u_inputTexture, v_uv); + return; + } + vec2 param = v_uv; + vec4 _139 = _f2(u_inputTexture, param); + vec4 _t4 = _139; + float param_1 = 0.0; + float param_2 = u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + vec4 _t6 = _139 * _146; + vec2 _t7 = v_uv; + if (u_spaceDither > 9.9999997473787516355514526367188e-06) + { + vec2 param_3 = v_uv; + _t7 += (vec2(u_stepX, u_stepY) * (u_spaceDither * _f0(param_3))); + } + vec2 _t9 = _t7; + for (mediump int _t10 = 1; _t10 <= 1024; _t10++) + { + mediump float _187 = float(_t10); + if (_187 > u_sampleX) + { + break; + } + float _197 = _187 * u_stepX; + float param_4 = _197; + float param_5 = u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (u_borderType == 1) + { + _t9.x = 0.0; + vec2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, param_6) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = -_t9.x; + vec2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, param_7) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, param_8) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (u_borderType == 1) + { + _t9.x = 1.0; + vec2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, param_9) * _203); + _t5 += _203; + } + else + { + if (u_borderType == 2) + { + _t5 += _203; + } + else + { + if (u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + vec2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, param_10) * _203); + _t5 += _203; + } + } + } + } + else + { + vec2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, param_11) * _203); + _t5 += _203; + } + } + _t6 /= vec4(_t5); + if (u_inverseGammaCorrection == 1) + { + vec4 _343 = _t6; + vec3 _348 = pow(_343.xyz, vec3(1.0 / u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + gl_FragData[0] = _t6; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderGLES/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag new file mode 100644 index 0000000000000000000000000000000000000000..ed17f350bb8d6a7aae2efae6967f3f5cfea25d52 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleY; + float u_sigmaY; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _108 = _t3; + float3 _114 = pow(_108.xyz, float3(u_gamma)); + _t3.x = _114.x; + _t3.y = _114.y; + _t3.z = _114.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _49 = fract(float3(((_p0 * u_ScreenParams.xy) + float2(0.33329999446868896484375)).xyx) * 0.103100001811981201171875); + float3 _t1 = _49 + float3(dot(_49, _49.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleY < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _142 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _142; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaY; + float _149 = _f1(param_1, param_2); + float _t5 = _149; + float4 _t6 = _142 * _149; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _190 = float(_t10); + if (_190 > buffer.u_sampleY) + { + break; + } + float _200 = _190 * buffer.u_stepY; + float param_4 = _200; + float param_5 = buffer.u_sigmaY; + float _206 = _f1(param_4, param_5); + _t9.y = _t7.y - _200; + if (_t9.y < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = -_t9.y; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + _t9.y = _t7.y + _200; + if (_t9.y > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.y = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _206; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.y = 2.0 - _t9.y; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _206); + _t5 += _206; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _346 = _t6; + float3 _351 = pow(_346.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _351.x; + _t6.y = _351.y; + _t6.z = _351.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/3cdb1c4f5b7f78cd677e4d9e4208c2f6.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag new file mode 100644 index 0000000000000000000000000000000000000000..4455c3ccad0aafdc2da5e788123a05a30d33bdcc --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.frag @@ -0,0 +1,180 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float4 u_ScreenParams; + int u_inverseGammaCorrection; + float u_gamma; + float u_sampleX; + float u_sigmaX; + float u_spaceDither; + float u_stepX; + float u_stepY; + int u_borderType; + int u_blurAlpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f2(texture2d _p0, sampler _p0Smplr, thread const float2& _p1, constant int& u_inverseGammaCorrection, constant float& u_gamma) +{ + float4 _t3 = _p0.sample(_p0Smplr, _p1); + if (u_inverseGammaCorrection == 1) + { + float4 _105 = _t3; + float3 _111 = pow(_105.xyz, float3(u_gamma)); + _t3.x = _111.x; + _t3.y = _111.y; + _t3.z = _111.z; + } + return _t3; +} + +static inline __attribute__((always_inline)) +float _f1(thread const float& _p0, thread const float& _p1) +{ + return exp((((-0.5) * _p0) * _p0) / (_p1 * _p1)); +} + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0, constant float4& u_ScreenParams) +{ + float3 _46 = fract(float3((_p0 * u_ScreenParams.xy).xyx) * 0.103100001811981201171875); + float3 _t1 = _46 + float3(dot(_46, _46.yzx + float3(33.3300018310546875))); + return (fract(fract((_t1.x + _t1.y) * _t1.z)) * 2.0) - 1.0; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_inputTexture [[texture(0)]], sampler u_inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + if (buffer.u_sampleX < 9.9999997473787516355514526367188e-06) + { + out.o_fragColor = u_inputTexture.sample(u_inputTextureSmplr, in.v_uv); + return out; + } + float2 param = in.v_uv; + float4 _139 = _f2(u_inputTexture, u_inputTextureSmplr, param, buffer.u_inverseGammaCorrection, buffer.u_gamma); + float4 _t4 = _139; + float param_1 = 0.0; + float param_2 = buffer.u_sigmaX; + float _146 = _f1(param_1, param_2); + float _t5 = _146; + float4 _t6 = _139 * _146; + float2 _t7 = in.v_uv; + if (buffer.u_spaceDither > 9.9999997473787516355514526367188e-06) + { + float2 param_3 = in.v_uv; + _t7 += (float2(buffer.u_stepX, buffer.u_stepY) * (buffer.u_spaceDither * _f0(param_3, buffer.u_ScreenParams))); + } + float2 _t9 = _t7; + for (int _t10 = 1; _t10 <= 1024; _t10++) + { + float _187 = float(_t10); + if (_187 > buffer.u_sampleX) + { + break; + } + float _197 = _187 * buffer.u_stepX; + float param_4 = _197; + float param_5 = buffer.u_sigmaX; + float _203 = _f1(param_4, param_5); + _t9.x = _t7.x - _197; + if (_t9.x < 0.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 0.0; + float2 param_6 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_6, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = -_t9.x; + float2 param_7 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_7, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_8 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_8, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + _t9.x = _t7.x + _197; + if (_t9.x > 1.0) + { + if (buffer.u_borderType == 1) + { + _t9.x = 1.0; + float2 param_9 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_9, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + else + { + if (buffer.u_borderType == 2) + { + _t5 += _203; + } + else + { + if (buffer.u_borderType == 3) + { + _t9.x = 2.0 - _t9.x; + float2 param_10 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_10, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + } + } + else + { + float2 param_11 = _t9; + _t6 += (_f2(u_inputTexture, u_inputTextureSmplr, param_11, buffer.u_inverseGammaCorrection, buffer.u_gamma) * _203); + _t5 += _203; + } + } + _t6 /= float4(_t5); + if (buffer.u_inverseGammaCorrection == 1) + { + float4 _343 = _t6; + float3 _348 = pow(_343.xyz, float3(1.0 / buffer.u_gamma)); + _t6.x = _348.x; + _t6.y = _348.y; + _t6.z = _348.z; + } + if (buffer.u_blurAlpha == 0) + { + _t6.w = _t4.w; + } + out.o_fragColor = _t6; + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiGaussianBlur/xshader/shaderLib/shaderMetal/fb87d49c516c36d90d1c3bd5cd8dfdc4.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua new file mode 100644 index 0000000000000000000000000000000000000000..438a547f7d5c96047e2f183309e2a7d7200347e7 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/lua/LumiLayer.lua @@ -0,0 +1,416 @@ +local exports = exports or {} +local LumiLayer = LumiLayer or {} +LumiLayer.__index = LumiLayer +---@class LumiLayer : ScriptComponent +---@field hasTransform boolean +---@field active_cam_fovx number +---@field compositeSize Vector2f +---@field layerSize Vector2f +---@field anchorPoint Vector3f +---@field orientation Vector3f +---@field position Vector3f +---@field scale Vector3f +---@field xRotation number [UI(Range={-360, 360}, Drag)] +---@field yRotation number [UI(Range={-360, 360}, Drag)] +---@field rotation number [UI(Range={-360, 360}, Drag)] +---@field opacity number [UI(Range={0, 100}, Drag)] +---@field mirrorEdge boolean +---@field hasMatte boolean +---@field matteMode string [UI(Option={"Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte"})] +---@field maskTex Texture +---@field hasBlend boolean +---@field blendMode string [UI(Option={"Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve"})] +---@field layerType string [UI(Option={"Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence"})] +---@field baseTex Texture +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local MatteMode = { + "Alpha Matte", "Luma Matte", "Alpha Inverted Matte", "Luma Inverted Matte", +} +setmetatable(MatteMode, {__index = function(_, _) return MatteMode[1] end}) + +local MatteModeIndex = {} +for index, value in ipairs(MatteMode) do MatteModeIndex[value] = index - 1 end +setmetatable(MatteModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported matte mode: " .. key) + return 0 + end +}) + +local BlendMode = { + "Normal", "Add", "Multiply", "Difference", "Overlay", "Darken", "Lighten", "Soft Light", "Hard Light", "Hue", "Saturation", "Color", "Screen", "Color Burn", "Linear Burn", "Color Dodge", "Linear Dodge", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Exclusion", "Subtract", "Divide", "Luminosity", "Lighter Color", "Darker Color", "Dissolve", +} +setmetatable(BlendMode, {__index = function(_, _) return BlendMode[1] end}) + +local BlendModeIndex = {} +for index, value in ipairs(BlendMode) do BlendModeIndex[value] = index - 1 end +setmetatable(BlendModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported blend mode: " .. key) + return 0 + end +}) + +local LayerType = { + "Adjustment", "Precomp", "Solid", "Image", "Video", "Sequence", +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +function LumiLayer.new(construct, ...) + local self = setmetatable({}, LumiLayer) + + self.TAG = AE_EFFECT_TAG + + self.InputTex = nil + self.OutputTex = nil + self.aeTime = -1 + + -- TRS + self.hasTransform = false + self.active_cam_fovx = 39.6 + self.compositeSize = Amaz.Vector2f(1080, 1080) + self.layerSize = Amaz.Vector2f(1080, 1080) + + self.anchorPoint = Amaz.Vector3f(0, 0, 0) + self.position = Amaz.Vector3f(0, 0, 0) + self.scale = Amaz.Vector3f(100, 100, 100) + self.orientation = Amaz.Vector3f(0, 0, 0) + self.rotation = 0 + self.xRotation = 0 + self.yRotation = 0 + self.opacity = 100 + + self.p0_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p0_position = Amaz.Vector3f(0, 0, 0) + self.p0_scale = Amaz.Vector3f(100, 100, 100) + self.p0_orientation = Amaz.Vector3f(0, 0, 0) + self.p0_rotation = 0 + self.p0_xRotation = 0 + self.p0_yRotation = 0 + + self.p1_anchorPoint = Amaz.Vector3f(0, 0, 0) + self.p1_position = Amaz.Vector3f(0, 0, 0) + self.p1_scale = Amaz.Vector3f(100, 100, 100) + self.p1_orientation = Amaz.Vector3f(0, 0, 0) + self.p1_rotation = 0 + self.p1_xRotation = 0 + self.p1_yRotation = 0 + + self.expandRight = 0.0 + self.expandLeft = 0.0 + self.expandUp = 0.0 + self.expandDown = 0.0 + self.mirrorEdge = false + + -- Matte + self.hasMatte = false + self.matteMode = "Alpha" + self.matteDuration = {} + self.maskTex = nil + + -- Blend + self.hasBlend = true + self.blendMode = "Normal" + self.isVisible = true + self.layerType = 'Adjustment' + self.baseTex = nil + self.srcDuration = {} + self.baseDuration = {} + + -- for test + if false then + self.aeTime = 1 + self.srcDuration = {{0, 6}} + self.baseDuration = {{0, 6}} + end + + return self +end + +function LumiLayer:setVisible(visible) + self.isVisible = visible +end + +function LumiLayer:setEntityVisible(entity, visible) + local transforms = entity:getComponentsRecursive("Transform") + for i = 0, transforms:size() - 1 do + local transform = transforms:get(i) + if transform then + transform.entity.visible = visible + end + end + entity.visible = visible +end + +function LumiLayer:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.layerEntity = self.entity:searchEntity('LayerCamera'); + self.camera = self.layerEntity:getComponent('Camera') + self.expand_tile_trans = self.entity:searchEntity("expand_tile"):getComponent("Transform") + self.father_trans = self.entity:searchEntity("father_trans"):getComponent("Transform") + self.child_trans = self.entity:searchEntity("child_trans"):getComponent("Transform") + self.p0_father_trans = self.entity:searchEntity("p0_father_trans"):getComponent("Transform") + self.p0_child_trans = self.entity:searchEntity("p0_child_trans"):getComponent("Transform") + self.p1_father_trans = self.entity:searchEntity("p1_father_trans"):getComponent("Transform") + self.p1_child_trans = self.entity:searchEntity("p1_child_trans"):getComponent("Transform") + self.renderer = self.entity:searchEntity('expand_tile'):getComponent('MeshRenderer') + self.renderer.useFrustumCulling = false + self.material = self.renderer.material +end + +local PositionDict = { + xPosition = {'position', 'x'}, + yPosition = {'position', 'y'}, + zPosition = {'position', 'z'}, + p0_xPosition = {'p0_position', 'x'}, + p0_yPosition = {'p0_position', 'y'}, + p0_zPosition = {'p0_position', 'z'}, + p1_xPosition = {'p1_position', 'x'}, + p1_yPosition = {'p1_position', 'y'}, + p1_zPosition = {'p1_position', 'z'}, +} + +function LumiLayer:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if key == 'position' + or key == 'anchorPoint' + or key == 'scale' + or key == 'orientation' + or key == 'p0_position' + or key == 'p0_anchorPoint' + or key == 'p0_scale' + or key == 'p0_orientation' + or key == 'p1_position' + or key == 'p1_anchorPoint' + or key == 'p1_scale' + or key == 'p1_orientation' + then + if value.z ~= nil then + _setEffectAttr(key, value) + else + -- Vector2f to Vector3f + _setEffectAttr(key, Amaz.Vector3f(value.x, value.y, 0)) + end + elseif PositionDict[key] ~= nil then + local newKey = PositionDict[key][1] + local dimension = PositionDict[key][2] + self[newKey][dimension] = value + _setEffectAttr(newKey, self[newKey]) + elseif key == 'blendMode' then + _setEffectAttr(key, BlendMode[value + 1]) + elseif key == 'matteMode' then + _setEffectAttr(key, MatteMode[value + 1]) + elseif key == 'layerType' then + if type(value) == 'string' then + _setEffectAttr(key, value) + else + _setEffectAttr(key, LayerType[value + 1]) + end + else + _setEffectAttr(key, value) + end +end + +function LumiLayer:_rotateByAEAxis(_trans, _direction, _euler_angle) + -- ae xyz, editor yxz + local right = Amaz.Vector3f(1.0, 0.0, 0.0) + local up = Amaz.Vector3f(0.0, 1.0, 0.0) + local forward = Amaz.Vector3f(0.0, 0.0, 1.0) + + local cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_direction.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_direction.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_direction.z)) + + up = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, up) + right = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, right) + forward = Amaz.Quaternionf.rotateVectorByQuat(cur_orientation, forward) + + cur_orientation = Amaz.Quaternionf.axisAngleToQuaternion(right, math.rad(_euler_angle.x)) + * Amaz.Quaternionf.axisAngleToQuaternion(up, -math.rad(_euler_angle.y)) + * Amaz.Quaternionf.axisAngleToQuaternion(forward, -math.rad(_euler_angle.z)) + * cur_orientation + + _trans.localOrientation = cur_orientation +end + +function LumiLayer:updateTRS(ratio) + self.expand_tile_trans.localScale = Amaz.Vector3f(1.0+self.expandRight+self.expandLeft, 1.0+self.expandUp+self.expandDown, 1.0) + self.expand_tile_trans.localPosition = Amaz.Vector3f( + self.expandRight-self.expandLeft, + self.expandUp-self.expandDown, + 0.0 + ) + + local ratio_c = self.compositeSize.x / self.compositeSize.y + local pos_z0 = ratio / math.tan(math.rad(self.active_cam_fovx * 0.5)) + local compositeSizeZ = self.compositeSize.y * ratio_c / ratio + -- Amaz.LOGE(self.TAG, "compositeSizeZ: "..compositeSizeZ) + self.camera.fovy = 2 * math.deg(math.atan(1 / pos_z0)) + + local rotate = Amaz.Vector3f(self.xRotation, self.yRotation, self.rotation) + self:_rotateByAEAxis(self.father_trans, self.orientation, rotate) + self.father_trans.localPosition = Amaz.Vector3f( + (self.position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.position.y / self.compositeSize.y - 0.5) * 2, + -self.position.z * 2 / compositeSizeZ + ) + self.child_trans.localPosition = Amaz.Vector3f( + -(self.anchorPoint.x / self.layerSize.x - 0.5) * 2 * ratio, + -(1.0 - self.anchorPoint.y / self.layerSize.y - 0.5) * 2, + self.anchorPoint.z * 2 / compositeSizeZ + ) + self.child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 0 + rotate = Amaz.Vector3f(self.p0_xRotation, self.p0_yRotation, self.p0_rotation) + self:_rotateByAEAxis(self.p0_father_trans, self.p0_orientation, rotate) + self.p0_father_trans.localPosition = Amaz.Vector3f( + (self.p0_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p0_position.y / self.compositeSize.y - 0.5) * 2, + -self.p0_position.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localPosition = Amaz.Vector3f( + -(self.p0_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p0_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p0_anchorPoint.z * 2 / compositeSizeZ + ) + self.p0_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + -- parent 1 + rotate = Amaz.Vector3f(self.p1_xRotation, self.p1_yRotation, self.p1_rotation) + self:_rotateByAEAxis(self.p1_father_trans, self.p1_orientation, rotate) + self.p1_father_trans.localPosition = Amaz.Vector3f( + (self.p1_position.x / self.compositeSize.x - 0.5) * 2 * ratio, + (1.0 - self.p1_position.y / self.compositeSize.y - 0.5) * 2, + -pos_z0 - self.p1_position.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localPosition = Amaz.Vector3f( + -(self.p1_anchorPoint.x / self.compositeSize.x - 0.5) * 2 * ratio, + -(1.0 - self.p1_anchorPoint.y / self.compositeSize.y - 0.5) * 2, + self.p1_anchorPoint.z * 2 / compositeSizeZ + ) + self.p1_child_trans.localEulerAngle = Amaz.Vector3f(0, 0, 0) + + self.father_trans.localScale = Amaz.Vector3f( + self.scale.x / 100.0 * (self.layerSize.x / self.compositeSize.x), + self.scale.y / 100.0 * (self.layerSize.y / self.compositeSize.y), + self.scale.z / 100.0 + ) + self.child_trans.localScale = Amaz.Vector3f(ratio, 1, 1) + self.p0_father_trans.localScale = self.p0_scale / 100.0 + self.p1_father_trans.localScale = self.p1_scale / 100.0 + + local mMat = self.expand_tile_trans:getWorldMatrix() + local vMat = self.camera:getWorldToCameraMatrix() + local pMat = self.camera.projectionMatrix + + return {vMat * mMat, pMat:invert_Full()} +end + +function LumiLayer:onUpdate(comp, deltaTime) + self.opacity = clamp(self.opacity, 0, 100) + local trsOpacity = 1.0 + local blendOpacity = 1.0 + if self.layerType == 'Adjustment' then + blendOpacity = self.opacity / 100.0 + else + trsOpacity = self.opacity / 100.0 + end + + local hasSrcTexture = false + if self.isVisible then + for _, duration in ipairs(self.srcDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasSrcTexture = true + break + end + end + end + + local needTrs = self.hasTransform and hasSrcTexture + local visible = needTrs or self.hasMatte or self.hasBlend + if self.layerEntity.visible ~= visible then + self:setEntityVisible(self.layerEntity, visible) + end + if visible == false then + return + end + + self.camera.renderTexture = self.OutputTex + self.material:setTex('u_sourceTexture', self.InputTex) + self.material:setTex('u_baseTexure', self.baseTex) + self.material:setTex('u_maskTexture', self.maskTex) + self.material:setInt('u_layerType', self.layerType == 'Adjustment' and 1 or 0) + + if needTrs then + local ratio = self.OutputTex.width / self.OutputTex.height + local mvp = self:updateTRS(ratio) + self.material:setInt('u_hasTrs', 1) + self.material:setMat4('u_mvMat', mvp[1]) + self.material:setMat4('u_pMat', mvp[2]) + self.material:setFloat('u_alpha', trsOpacity) + self.material:setFloat('u_mirrorEdge', self.mirrorEdge and 1 or 0) + else + self.material:setInt('u_hasTrs', 0) + end + + if hasSrcTexture then + self.material:setInt("u_hasSourceTexture", 1) + else + self.material:setInt("u_hasSourceTexture", 0) + end + + local enableMatte = false + if self.hasMatte and self.maskTex then + for _, duration in ipairs(self.matteDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + enableMatte = true + break + end + end + end + + if self.hasBlend then + local hasBaseTexture = false + for _, duration in ipairs(self.baseDuration) do + if duration[1] <= self.aeTime and self.aeTime <= duration[2] then + hasBaseTexture = true + break + end + end + self.material:setInt("u_hasBlend", 1) + self.material:setInt("u_hasBaseTexture", hasBaseTexture and 1 or 0) + self.material:setInt("u_blendMode", BlendModeIndex[self.blendMode]) + self.material:setFloat("u_layerOpacity", blendOpacity) + else + self.material:setInt("u_hasBlend", 0) + end + + if self.hasMatte then + self.material:setInt('u_hasMatte', 1) + self.material:setInt("u_enableMatte", enableMatte and 1 or 0) + self.material:setInt("u_matteMode", MatteModeIndex[self.matteMode]) + else + self.material:setInt('u_hasMatte', 0) + end +end + +exports.LumiLayer = LumiLayer +return exports diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..01561dcc590f6fbe28e9efccd32698c72f5eeb0f --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,240 @@ +precision highp float; +precision highp int; + +uniform mediump int u_enableMatte; +uniform mediump sampler2D u_maskTexture; +uniform mediump int u_matteMode; +uniform mediump int u_layerType; +uniform mediump int u_hasMatte; +uniform float u_layerOpacity; +uniform mediump int u_hasBlend; +uniform mediump int u_hasBaseTexture; +uniform mediump sampler2D u_baseTexure; +uniform mediump int u_hasSourceTexture; +uniform mediump int u_hasTrs; +uniform mat4 u_mvMat; +uniform mat4 u_pMat; +uniform float u_mirrorEdge; +uniform mediump sampler2D u_sourceTexture; +uniform float u_alpha; + +varying vec2 uv0; + +vec4 _f1(vec3 _p0, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4) +{ + vec3 _61 = _p3 - _p2; + vec3 _65 = _p4 - _p2; + vec3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return vec4(-1.0); + } + vec3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return vec4(-1.0); + } + vec3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return vec4(-1.0); + } + return vec4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +vec2 _f2(mat4 _p0, mat4 _p1, vec2 _p2) +{ + vec3 _162 = (_p0 * vec4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + vec3 _168 = (_p0 * vec4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _173 = (_p0 * vec4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + vec3 _178 = (_p0 * vec4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + vec4 _189 = _p1 * vec4((_p2 * 2.0) - vec2(1.0), 0.0, 1.0); + vec4 _t17 = _189; + vec3 _206 = normalize((_189.xyz / vec3(_t17.w)) - vec3(0.0)); + vec3 param = vec3(0.0); + vec3 param_1 = _206; + vec3 _214 = (_p0 * vec4(-10.0, -10.0, 0.0, 1.0)).xyz; + vec3 param_2 = _214; + vec3 param_3 = _162; + vec3 param_4 = _173; + vec4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + vec3 param_5 = vec3(0.0); + vec3 param_6 = _206; + vec3 param_7 = _178; + vec3 param_8 = _168; + vec3 _231 = (_p0 * vec4(10.0, 10.0, 0.0, 1.0)).xyz; + vec3 param_9 = _231; + vec4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + vec3 param_10 = vec3(0.0); + vec3 param_11 = _206; + vec3 param_12 = _214; + vec3 param_13 = _173; + vec3 param_14 = _162; + vec4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + vec3 param_15 = vec3(0.0); + vec3 param_16 = _206; + vec3 param_17 = _178; + vec3 param_18 = _231; + vec3 param_19 = _168; + vec4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + vec2 _397 = (((((((vec2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (vec2(5.5, -4.5) * _t21.x)) + (vec2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((vec2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (vec2(5.5, -4.5) * _t22.x)) + (vec2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((vec2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (vec2(-4.5, 5.5) * _t23.x)) + (vec2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((vec2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (vec2(5.5) * _t24.x)) + (vec2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (vec2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +vec2 _f4(vec2 _p0) +{ + return abs(mod(_p0 - vec2(1.0), vec2(2.0)) - vec2(1.0)); +} + +float _f3(vec2 _p0) +{ + vec2 _t30 = step(vec2(0.0), _p0) * step(_p0, vec2(1.0)); + return _t30.x * _t30.y; +} + +float _f0(vec3 _p0) +{ + return dot(_p0, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +vec4 _f5(vec4 _p0) +{ + vec4 _t31 = vec4(0.0); + if (u_enableMatte == 1) + { + _t31 = texture2D(u_maskTexture, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + vec3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + vec3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +vec4 _f6(inout vec4 _p0, inout vec4 _p1) +{ + float _483 = _p0.w; + vec4 _486 = _p0; + vec3 _489 = _486.xyz / vec3(max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + vec4 _500 = _p1; + vec3 _503 = _500.xyz / vec3(max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + vec4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + vec4 _t34 = vec4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + vec4 param = vec4(1.0); + _t35 = _f5(param).w; + } + vec4 _551 = mix(_p1, vec4(_t33.xyz, _p0.w), vec4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + vec3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + vec3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +void main() +{ + vec4 _t36 = vec4(0.0); + bool _614 = u_hasBlend == 1; + if (_614) + { + if (u_hasBaseTexture == 1) + { + _t36 = texture2D(u_baseTexure, uv0); + } + if (u_hasSourceTexture == 0) + { + gl_FragData[0] = _t36; + return; + } + } + vec4 _t37 = vec4(0.0); + if (u_hasTrs == 1) + { + mat4 param = u_mvMat; + mat4 param_1 = u_pMat; + vec2 param_2 = uv0; + vec2 _652 = _f2(param, param_1, param_2); + float _656 = step(u_mirrorEdge, 0.5); + vec2 param_3 = _652; + vec2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + vec2 param_4 = _666; + _t37 = (texture2D(u_sourceTexture, _666) * u_alpha) * _f3(param_4); + } + else + { + if (u_hasSourceTexture == 1) + { + _t37 = texture2D(u_sourceTexture, uv0); + } + } + if ((u_layerType != 1) && (u_hasMatte == 1)) + { + vec4 param_5 = _t37; + _t37 = _f5(param_5); + } + if (_614) + { + vec4 param_6 = _t37; + vec4 param_7 = _t36; + vec4 _704 = _f6(param_6, param_7); + _t37 = _704; + } + gl_FragData[0] = _t37; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..705dd9f8b691def7eaafc9c1b6e2528c0b0c0165 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderGLES/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag new file mode 100644 index 0000000000000000000000000000000000000000..7b5f204904818053699abc060be6bfa62f2ab74e --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.frag @@ -0,0 +1,268 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +struct buffer_t +{ + int u_enableMatte; + int u_matteMode; + int u_layerType; + int u_hasMatte; + float u_layerOpacity; + int u_hasBlend; + int u_hasBaseTexture; + int u_hasSourceTexture; + int u_hasTrs; + float4x4 u_mvMat; + float4x4 u_pMat; + float u_mirrorEdge; + float u_alpha; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float4 _f1(thread const float3& _p0, thread const float3& _p1, thread const float3& _p2, thread const float3& _p3, thread const float3& _p4) +{ + float3 _61 = _p3 - _p2; + float3 _65 = _p4 - _p2; + float3 _69 = cross(_p1, _65); + float _74 = dot(_61, _69); + if (_74 <= 1.0000000116860974230803549289703e-07) + { + return float4(-1.0); + } + float3 _87 = _p0 - _p2; + float _93 = dot(_87, _69) / _74; + if ((_93 < 0.0) || (_93 > 1.0)) + { + return float4(-1.0); + } + float3 _107 = cross(_87, _61); + float _113 = dot(_p1, _107) / _74; + bool _115 = _113 < 0.0; + bool _123; + if (!_115) + { + _123 = (_93 + _113) > 1.0; + } + else + { + _123 = _115; + } + if (_123) + { + return float4(-1.0); + } + return float4(_93, _113, dot(_65, _107) / _74, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float4x4& _p0, thread const float4x4& _p1, thread const float2& _p2) +{ + float3 _162 = (_p0 * float4(10.0000095367431640625, -10.0, 0.0, 1.0)).xyz; + float3 _168 = (_p0 * float4(10.0, -10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _173 = (_p0 * float4(-10.0, 10.0000095367431640625, 0.0, 1.0)).xyz; + float3 _178 = (_p0 * float4(-10.0000095367431640625, 10.0, 0.0, 1.0)).xyz; + float4 _189 = _p1 * float4((_p2 * 2.0) - float2(1.0), 0.0, 1.0); + float4 _t17 = _189; + float3 _206 = fast::normalize((_189.xyz / float3(_t17.w)) - float3(0.0)); + float3 param = float3(0.0); + float3 param_1 = _206; + float3 _214 = (_p0 * float4(-10.0, -10.0, 0.0, 1.0)).xyz; + float3 param_2 = _214; + float3 param_3 = _162; + float3 param_4 = _173; + float4 _t21 = _f1(param, param_1, param_2, param_3, param_4); + float3 param_5 = float3(0.0); + float3 param_6 = _206; + float3 param_7 = _178; + float3 param_8 = _168; + float3 _231 = (_p0 * float4(10.0, 10.0, 0.0, 1.0)).xyz; + float3 param_9 = _231; + float4 _t22 = _f1(param_5, param_6, param_7, param_8, param_9); + float3 param_10 = float3(0.0); + float3 param_11 = _206; + float3 param_12 = _214; + float3 param_13 = _173; + float3 param_14 = _162; + float4 _t23 = _f1(param_10, param_11, param_12, param_13, param_14); + float3 param_15 = float3(0.0); + float3 param_16 = _206; + float3 param_17 = _178; + float3 param_18 = _231; + float3 param_19 = _168; + float4 _t24 = _f1(param_15, param_16, param_17, param_18, param_19); + float2 _397 = (((((((float2(-4.5) * ((1.0 - _t21.x) - _t21.y)) + (float2(5.5, -4.5) * _t21.x)) + (float2(-4.5, 5.5) * _t21.y)) * step(0.0, _t21.w)) + ((((float2(-4.5, 5.5) * ((1.0 - _t22.x) - _t22.y)) + (float2(5.5, -4.5) * _t22.x)) + (float2(5.5) * _t22.y)) * (step(_t21.w, 0.0) * step(0.0, _t22.w)))) + ((((float2(-4.5) * ((1.0 - _t23.x) - _t23.y)) + (float2(-4.5, 5.5) * _t23.x)) + (float2(5.5, -4.5) * _t23.y)) * ((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(0.0, _t23.w)))) + ((((float2(-4.5, 5.5) * ((1.0 - _t24.x) - _t24.y)) + (float2(5.5) * _t24.x)) + (float2(5.5, -4.5) * _t24.y)) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(0.0, _t24.w)))) + (float2(-10000.0) * (((step(_t21.w, 0.0) * step(_t22.w, 0.0)) * step(_t23.w, 0.0)) * step(_t24.w, 0.0))); + return _397; +} + +static inline __attribute__((always_inline)) +float2 _f4(thread const float2& _p0) +{ + return abs(mod(_p0 - float2(1.0), float2(2.0)) - float2(1.0)); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float2& _p0) +{ + float2 _t30 = step(float2(0.0), _p0) * step(_p0, float2(1.0)); + return _t30.x * _t30.y; +} + +static inline __attribute__((always_inline)) +float _f0(thread const float3& _p0) +{ + return dot(_p0, float3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread const float4& _p0, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode) +{ + float4 _t31 = float4(0.0); + if (u_enableMatte == 1) + { + _t31 = u_maskTexture.sample(u_maskTextureSmplr, uv0); + } + float _t32 = _t31.w; + if (u_matteMode == 1) + { + float3 param = _t31.xyz; + _t32 = _f0(param); + } + else + { + if (u_matteMode == 2) + { + _t32 = 1.0 - _t31.w; + } + else + { + if (u_matteMode == 3) + { + float3 param_1 = _t31.xyz; + _t32 = 1.0 - _f0(param_1); + } + } + } + return _p0 * _t32; +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, thread float4& _p1, constant int& u_enableMatte, texture2d u_maskTexture, sampler u_maskTextureSmplr, thread float2& uv0, constant int& u_matteMode, constant int& u_layerType, constant int& u_hasMatte, constant float& u_layerOpacity) +{ + float _483 = _p0.w; + float4 _486 = _p0; + float3 _489 = _486.xyz / float3(fast::max(_483, 9.9999997473787516355514526367188e-06)); + _p0.x = _489.x; + _p0.y = _489.y; + _p0.z = _489.z; + float _498 = _p1.w; + float4 _500 = _p1; + float3 _503 = _500.xyz / float3(fast::max(_498, 9.9999997473787516355514526367188e-06)); + _p1.x = _503.x; + _p1.y = _503.y; + _p1.z = _503.z; + float4 _t33 = _p1; + _t33.x = _p0.xyz.x; + _t33.y = _p0.xyz.y; + _t33.z = _p0.xyz.z; + float4 _t34 = float4(0.0); + if (u_layerType == 1) + { + float _t35 = 1.0; + if (u_hasMatte == 1) + { + float4 param = float4(1.0); + _t35 = _f5(param, u_enableMatte, u_maskTexture, u_maskTextureSmplr, uv0, u_matteMode).w; + } + float4 _551 = mix(_p1, float4(_t33.xyz, _p0.w), float4(u_layerOpacity * _t35)); + _t34 = _551; + float _553 = _t34.w; + float3 _556 = _551.xyz * _553; + _t34.x = _556.x; + _t34.y = _556.y; + _t34.z = _556.z; + } + else + { + float3 _591 = (((_p1.xyz * _p1.w) * (1.0 - _p0.w)) + ((_p0.xyz * _p0.w) * (1.0 - _p1.w))) + (_t33.xyz * (_p0.w * _p1.w)); + _t34.x = _591.x; + _t34.y = _591.y; + _t34.z = _591.z; + _t34.w = _p0.w + (_p1.w * (1.0 - _p0.w)); + } + return _t34; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d u_maskTexture [[texture(0)]], texture2d u_baseTexure [[texture(1)]], texture2d u_sourceTexture [[texture(2)]], sampler u_maskTextureSmplr [[sampler(0)]], sampler u_baseTexureSmplr [[sampler(1)]], sampler u_sourceTextureSmplr [[sampler(2)]]) +{ + main0_out out = {}; + float4 _t36 = float4(0.0); + bool _614 = buffer.u_hasBlend == 1; + if (_614) + { + if (buffer.u_hasBaseTexture == 1) + { + _t36 = u_baseTexure.sample(u_baseTexureSmplr, in.uv0); + } + if (buffer.u_hasSourceTexture == 0) + { + out.o_fragColor = _t36; + return out; + } + } + float4 _t37 = float4(0.0); + if (buffer.u_hasTrs == 1) + { + float4x4 param = buffer.u_mvMat; + float4x4 param_1 = buffer.u_pMat; + float2 param_2 = in.uv0; + float2 _652 = _f2(param, param_1, param_2); + float _656 = step(buffer.u_mirrorEdge, 0.5); + float2 param_3 = _652; + float2 _666 = (_652 * _656) + (_f4(param_3) * (1.0 - _656)); + float2 param_4 = _666; + _t37 = (u_sourceTexture.sample(u_sourceTextureSmplr, _666) * buffer.u_alpha) * _f3(param_4); + } + else + { + if (buffer.u_hasSourceTexture == 1) + { + _t37 = u_sourceTexture.sample(u_sourceTextureSmplr, in.uv0); + } + } + if ((buffer.u_layerType != 1) && (buffer.u_hasMatte == 1)) + { + float4 param_5 = _t37; + _t37 = _f5(param_5, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode); + } + if (_614) + { + float4 param_6 = _t37; + float4 param_7 = _t36; + float4 _704 = _f6(param_6, param_7, buffer.u_enableMatte, u_maskTexture, u_maskTextureSmplr, in.uv0, buffer.u_matteMode, buffer.u_layerType, buffer.u_hasMatte, buffer.u_layerOpacity); + _t37 = _704; + } + out.o_fragColor = _t37; + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert new file mode 100644 index 0000000000000000000000000000000000000000..d7349349d1805ff40c01eddcceaf24b19c0e17d2 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiLayer/xshader/shaderLib/shaderMetal/311011f458f3dd960d75dc31e1ae2f74.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua new file mode 100644 index 0000000000000000000000000000000000000000..6670a8f824cf1a17667d535221716ea6ad383a38 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/lua/SGlow.lua @@ -0,0 +1,238 @@ +local exports = exports or {} +local SGlow = SGlow or {} +SGlow.__index = SGlow +---@class SGlow: ScriptComponent +---@field show string [UI(Option={"Result", "Threshold"})] +---@field brightness double [UI(Range={0, 50}, Drag)] +---@field threshold double [UI(Range={0, 1}, Drag)] +---@field thresholdAddColor Color [UI(NoAlpha)] +---@field glowColor Color [UI(NoAlpha)] +---@field glowWidth double [UI(Display="Glow Width", Range={0, 1}, Drag)] +---@field widthX double [UI(Display="Width X", Range={0, 5}, Drag)] +---@field widthY double [UI(Display="Width Y", Range={0, 5}, Drag)] +---@field widthRed double [UI(Display="Width Red", Range={0, 5}, Drag)] +---@field widthGreen double [UI(Display="Width Green", Range={0, 5}, Drag)] +---@field widthBlue double [UI(Display="Width Blue", Range={0, 5}, Drag)] +---@field combine string [UI(Option={"Screen", "Add", "Mult", "Difference", "Overlay"})] +---@field edgeMode string [UI(Option={"Transparent", "Reflect"})] +---@field glowFromAlpha double [UI(Range={0, 1}, Drag)] +---@field glowUnderSource double [UI(Range={0, 1}, Drag)] +---@field sourceOpacity double [UI(Range={0, 1}, Drag)] +---@field bgTexture Texture2D [UI(Type="Texture2D")] +---@field lightBackground double [UI(Range={0, 1}, Drag)] +---@field bgBrightness double [UI(Range={0, 1}, Drag)] +---@field quality double [UI(Range={0, 1}, Drag)] +---@field dither double [UI(Range={0, 1}, Slider)] +---@field InputTex Texture +---@field OutputTex Texture + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local CombineModeName = { + "Screen", "Add", "Mult", "Difference", "Overlay" +} +setmetatable(CombineModeName, {__index = function(_, _) return CombineModeName[1] end}) + +local CombineModeIndex = {} +for index, value in ipairs(CombineModeName) do + CombineModeIndex[value] = index - 1 +end +setmetatable(CombineModeIndex, { + __index = function(_, key) + Amaz.LOGE(AE_EFFECT_TAG, "Unsupported combine mode: " .. key) + return 0 + end +}) + +local EdgeModeName = { + "Transparent", "Reflect" +} +setmetatable(EdgeModeName, {__index = function(_, _) return EdgeModeName[1] end}) + +local EdgeModeIndex = {} +for index, value in ipairs(EdgeModeName) do EdgeModeIndex[value] = index - 1 end +setmetatable(EdgeModeIndex, {__index = function(_, _) return 0 end}) + +function SGlow.new(construct, ...) + local self = setmetatable({}, SGlow) + + self.InputTex = nil + self.OutputTex = nil + + self.threshold = 0.5 + self.thresholdAddColor = Amaz.Color(0., 0., 0.) + self.glowWidth = 0.1 + self.widthX = 1. + self.widthY = 1. + self.widthRed = 1. + self.widthGreen = 1.2 + self.widthBlue = 1.4 + self.brightness = 2. + self.glowColor = Amaz.Color(1., 1., 1.) + self.combine = "Screen" + self.edgeMode = "Reflect" + self.glowFromAlpha = 0. + self.glowUnderSource = 0. + self.sourceOpacity = 1. + self.bgTexture = nil + self.lightBackground = 0.0 + self.bgBrightness = 1.0 + self.show = "Result" + self.quality = 0.2 + self.dither = 0 + return self +end + +function SGlow:onStart(comp) + self.entity = comp.entity + self.TAG = AE_EFFECT_TAG .. ' ' .. self.entity.name + + self.blurTex = comp.properties:get('blurTex') + self.camMask = self.entity:searchEntity("MaskCamera"):getComponent("Camera") + self.camHorzBlurEntity = self.entity:searchEntity("BlurHorzCamera") + self.camVertBlurEntity = self.entity:searchEntity("BlurVertCamera") + self.camHorzBlurEntity2 = self.entity:searchEntity("BlurHorzCamera_2") + self.camVertBlurEntity2 = self.entity:searchEntity("BlurVertCamera_2") + self.camBlendEntity = self.entity:searchEntity("BlendCamera") + self.blendCamera = self.camBlendEntity:getComponent("Camera") + self.matMask = self.entity:searchEntity("PassMask"):getComponent("MeshRenderer").material + self.matHorzBlur = self.entity:searchEntity("PassHorzBlur"):getComponent("MeshRenderer").material + self.matVertBlur = self.entity:searchEntity("PassVertBlur"):getComponent("MeshRenderer").material + self.matHorzBlur2 = self.entity:searchEntity("PassHorzBlur_2"):getComponent("MeshRenderer").material + self.matVertBlur2 = self.entity:searchEntity("PassVertBlur_2"):getComponent("MeshRenderer").material + self.matBlend = self.entity:searchEntity("BlendPass"):getComponent("MeshRenderer").material + self.camHorzBlur = self.camHorzBlurEntity:getComponent("Camera") + self.camVertBlur = self.camVertBlurEntity:getComponent("Camera") + self.camHorzBlur2 = self.camHorzBlurEntity2:getComponent("Camera") + self.camVertBlur2 = self.camVertBlurEntity2:getComponent("Camera") +end + +function SGlow:setEffectAttr(key, value, comp) + local function _setEffectAttr(_key, _value) + if self[_key] ~= nil then + self[_key] = _value + if comp and comp.properties ~= nil then + comp.properties:set(_key, _value) + end + end + end + + if "combine" == key then + local combine = CombineModeName[value + 1] + _setEffectAttr(key, combine) + elseif "edgeMode" == key then + local edgeMode = EdgeModeName[value + 1] + _setEffectAttr(key, edgeMode) + elseif "show" == key then + local show = "Result" + if value == 1 then show = "Threshold" end + _setEffectAttr(key, show) + else + _setEffectAttr(key, value) + end +end + +function SGlow:onUpdate(comp, deltaTime) + self.matMask:setTex('inputTexture', self.InputTex) + self.blendCamera.renderTexture = self.OutputTex + + local isShowResult = self.show == 'Result' + self.camHorzBlurEntity.visible = isShowResult + self.camVertBlurEntity.visible = isShowResult + self.camHorzBlurEntity2.visible = isShowResult + self.camVertBlurEntity2.visible = isShowResult + self.camBlendEntity.visible = isShowResult + if isShowResult then + self.camMask.renderTexture = self.blurTex + else + self.camMask.renderTexture = self.OutputTex + end + + self.matMask:setFloat("glowFromAlpha", self.glowFromAlpha) + self.matMask:setFloat("threshold", self.threshold) + self.matMask:setVec3("color", Amaz.Vector3f(self.thresholdAddColor.r, self.thresholdAddColor.g, self.thresholdAddColor.b)) + + local blurWidth = Amaz.BuiltinObject:getInputTextureWidth() + local blurHeight = Amaz.BuiltinObject:getInputTextureHeight() + if self.OutputTex then + blurWidth = self.OutputTex.width + blurHeight = self.OutputTex.height + end + local blurSize = math.max(math.min(self.quality * 1200, 360), 120) + if blurWidth > blurSize then + blurHeight = blurHeight / blurWidth * blurSize + blurWidth = blurSize + end + local radius = self.glowWidth * blurWidth + -- Amaz.LOGS('tqh-log radius: ', '' .. radius) + local widthXR = (radius * self.widthX * self.widthRed) + local widthXG = (radius * self.widthX * self.widthGreen) + local widthXB = (radius * self.widthX * self.widthBlue) + local widthYR = (radius * self.widthY * self.widthRed) + local widthYG = (radius * self.widthY * self.widthGreen) + local widthYB = (radius * self.widthY * self.widthBlue) + -- local blurDegree = radius / math.max(w, h) + self.camHorzBlur.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur.renderTexture.height = math.floor(blurHeight) + self.camVertBlur.renderTexture.width = math.floor(blurWidth) + self.camVertBlur.renderTexture.height = math.floor(blurHeight) + self.camHorzBlur2.renderTexture.width = math.floor(blurWidth) + self.camHorzBlur2.renderTexture.height = math.floor(blurHeight) + self.camVertBlur2.renderTexture.width = math.floor(blurWidth) + self.camVertBlur2.renderTexture.height = math.floor(blurHeight) + local colorRadiusX = Amaz.Vector4f(widthXR, widthXG, widthXB, radius) + local colorRadiusY = Amaz.Vector4f(widthYR, widthYG, widthYB, radius) + self.matHorzBlur:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + self.matHorzBlur2:setVec4("ColorRadius", colorRadiusX) + self.matVertBlur2:setVec4("ColorRadius", colorRadiusY) + self.matHorzBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- w / 2 + self.matVertBlur2:setFloat("MaxRadius", 10+math.floor(100*self.quality)) -- h / 2 + local colorSigmaX = colorRadiusX / 2.4 + local colorSigmaY = colorRadiusY / 2.4 + colorSigmaX.x = math.pow(colorSigmaX.x, 2) * 2.0 + colorSigmaX.y = math.pow(colorSigmaX.y, 2) * 2.0 + colorSigmaX.z = math.pow(colorSigmaX.z, 2) * 2.0 + colorSigmaX.w = math.pow(colorSigmaX.w, 2) * 2.0 + colorSigmaY.x = math.pow(colorSigmaY.x, 2) * 2.0 + colorSigmaY.y = math.pow(colorSigmaY.y, 2) * 2.0 + colorSigmaY.z = math.pow(colorSigmaY.z, 2) * 2.0 + colorSigmaY.w = math.pow(colorSigmaY.w, 2) * 2.0 + self.matHorzBlur:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur:setFloat("threshold", self.threshold) + self.matVertBlur:setFloat("threshold", self.threshold) + self.matHorzBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur:setFloat("dither", self.dither) + self.matHorzBlur:setFloat("dither", self.dither) + self.matVertBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matHorzBlur2:setVec4("ColorSigma", colorSigmaX) + self.matVertBlur2:setVec4("ColorSigma", colorSigmaY) + self.matHorzBlur2:setFloat("threshold", self.threshold) + self.matVertBlur2:setFloat("threshold", self.threshold) + self.matHorzBlur2:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matVertBlur2:setFloat("dither", self.dither) + self.matHorzBlur2:setFloat("dither", self.dither) + self.matVertBlur:setInt("edgeMode", EdgeModeIndex[self.edgeMode]) + self.matBlend:setFloat("brightness", self.brightness) + self.matBlend:setFloat("threshold", self.threshold) + self.matBlend:setVec3("GlowColor", Amaz.Vector3f(self.glowColor.r, self.glowColor.g, self.glowColor.b)) + self.matBlend:setInt("combine", CombineModeIndex[self.combine]) + self.matBlend:setFloat("glowUnderSource", self.glowUnderSource) + self.matBlend:setFloat("sourceOpacity", self.sourceOpacity) + if self.bgTexture then + self.matBlend:setInt("hasBgTex", 1) + self.matBlend:setTex("bgTexture", self.bgTexture) + self.matBlend:setVec2("bgTextureSize", Amaz.Vector2f(self.bgTexture.width, self.bgTexture.height)) + else + self.matBlend:setInt("hasBgTex", 0) + end + self.matBlend:setFloat("lightBackground", self.lightBackground) + self.matBlend:setFloat("bgBrightness", self.bgBrightness) + self.matBlend:setTex("inputTexture", self.InputTex) +end + +exports.SGlow = SGlow +return exports diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd92cf1d93f341fc035e94dcae0f7d036bf1ea5d --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.xy; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..0d9bc95cd0170a6be8df9042804f1c07df3f4957 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,123 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +float _f4(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f2(float _p0, float _p1) +{ + vec2 _106 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t5 = _106 + vec2(dot(_106, _106.yx + vec2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +vec2 _f1(float _p0, float _p1) +{ + vec2 _t4 = vec2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +vec4 _f3(float _p0, float _p1) +{ + vec2 _136 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + vec2 _166 = uv0 + (_136 * vec2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + vec2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + vec2 _191 = uv0 - (_136 * vec2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + vec2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + vec2 _t9 = _f1(param_4, param_5); + return (texture2D(inputTexture, _166) * _t9.x) + (texture2D(inputTexture, _191) * _t9.y); +} + +vec4 _f5(inout vec4 _p0) +{ + vec4 _t10 = vec4(1.0); + vec4 _t11 = vec4(0.0); + float _251 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +vec4 _f0(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 param = texture2D(inputTexture, uv0); + vec4 _381 = _f5(param); + vec2 param_1 = _381.zw; + gl_FragData[0] = _f0(param_1); +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..5245ae0be09ab57a15f91128e8631378c062dca3 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(0.0, 0.0, _f0(param_6)) * _t11.x) + (vec4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.zw; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..4b17097f1ef491b30b76a8ae4c5d9c9330d09d90 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,41 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform float glowFromAlpha; +uniform float threshold; +uniform vec3 color; + +varying vec2 v_uv; + +float _f0(float _p0, float _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +void main() +{ + mediump vec4 _44 = texture2D(inputTexture, v_uv); + vec4 _t0 = _44; + vec3 _53 = mix(_44.xyz, vec3(1.0), vec3(glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = threshold + color.x; + float param_2 = _t0.y; + float param_3 = threshold + color.y; + float param_4 = _t0.z; + float param_5 = threshold + color.z; + gl_FragData[0] = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..ba6cf8435d4d91846b8bac0b369e0ff5b5bea0e5 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,135 @@ +precision highp float; +precision highp int; + +uniform mediump int edgeMode; +uniform vec4 u_ScreenParams; +uniform float dither; +uniform mediump sampler2D inputTexture; +uniform vec4 ColorRadius; +uniform float MaxRadius; +uniform vec4 ColorSigma; + +varying vec2 uv0; + +vec2 _f0(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +float _f5(float _p0, float _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +float _f3(float _p0, float _p1) +{ + vec2 _131 = fract(vec2(_p0, _p1) * 13.5170001983642578125); + vec2 _t7 = _131 + vec2(dot(_131, _131.yx + vec2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +vec2 _f2(float _p0, float _p1) +{ + vec2 _t6 = vec2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +vec4 _f4(float _p0, float _p1) +{ + vec2 _161 = vec2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + vec2 _191 = uv0 + (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + vec2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + vec2 _216 = uv0 - (_161 * vec2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + vec2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + vec2 _t11 = _f2(param_4, param_5); + vec4 param_6 = texture2D(inputTexture, _191); + vec4 param_7 = texture2D(inputTexture, _216); + return (vec4(_f0(param_6), 0.0, 0.0) * _t11.x) + (vec4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +vec4 _f6(inout vec4 _p0) +{ + vec4 _t12 = vec4(1.0); + vec4 _t13 = vec4(0.0); + float _285 = max(1.0, max(max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +vec4 _f1(vec2 _p0) +{ + return vec4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +void main() +{ + vec4 _t19 = vec4(0.0); + vec4 param = texture2D(inputTexture, uv0); + vec2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + vec4 param_1 = _t19; + vec4 _420 = _f6(param_1); + vec2 param_2 = _420.xy; + gl_FragData[0] = _f1(param_2); +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..70df85409cceb6f1c7dbaf4d82309fe98a8dc111 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 uv0; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + uv0 = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..9ebe9f8c465269378acf5385e490b21ef6e82de0 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,140 @@ +precision highp float; +precision highp int; + +uniform mediump sampler2D inputTexture; +uniform mediump int hasBgTex; +uniform vec4 u_ScreenParams; +uniform vec2 bgTextureSize; +uniform mediump sampler2D bgTexture; +uniform float sourceOpacity; +uniform float bgBrightness; +uniform mediump sampler2D blurTexture1; +uniform mediump sampler2D blurTexture2; +uniform vec3 GlowColor; +uniform float brightness; +uniform float glowUnderSource; +uniform float lightBackground; +uniform mediump int combine; + +varying vec2 v_uv; + +float _f0(vec2 _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +vec2 _f1(vec4 _p0) +{ + return vec2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +void main() +{ + mediump vec4 _73 = texture2D(inputTexture, v_uv); + vec4 _t2 = _73; + vec4 _t3 = vec4(0.0, 0.0, 0.0, _t2.w); + if (hasBgTex > 0) + { + vec2 _t4 = v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= vec2(0.5); + _t4.x *= (u_ScreenParams.x / bgTextureSize.x); + _t4.y *= (u_ScreenParams.y / bgTextureSize.y); + vec2 _120 = _t4; + vec2 _122 = _120 + vec2(0.5); + _t4 = _122; + vec2 param = _122; + _t3 = texture2D(bgTexture, _122) * _f0(param); + } + vec4 _135 = vec4(sourceOpacity); + _t3 = mix(_t3, _73, _135) * bgBrightness; + vec4 param_1 = texture2D(blurTexture1, v_uv); + vec4 param_2 = texture2D(blurTexture2, v_uv); + vec4 _158 = vec4(_f1(param_1), _f1(param_2)); + vec4 _t5 = _158; + vec3 _165 = _158.xyz * GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + vec4 _174 = _t5; + vec4 _175 = _174 * brightness; + _t5 = _175; + vec4 _192 = mix(_175, mix(_175, _73, _135), vec4(glowUnderSource)) * (1.0 - lightBackground); + vec4 _t6 = _192; + _t3 = clamp(_t3, vec4(0.0), vec4(1.0)); + vec4 _t8 = _73; + if (combine == 1) + { + vec3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (combine == 2) + { + vec3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (combine == 3) + { + vec3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + vec3 _337 = vec3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + vec3 _355 = vec3(1.0) - ((vec3(1.0) - _t3.xyz) * (vec3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + gl_FragData[0] = _t8; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..feaf33620b1973b7a1d3cbe696ef56e877e75719 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderGLES/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,11 @@ + +attribute vec2 a_position; +varying vec2 v_uv; +attribute vec2 a_texcoord0; + +void main() +{ + gl_Position = sign(vec4(a_position, 0.0, 1.0)); + v_uv = a_texcoord0; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag new file mode 100644 index 0000000000000000000000000000000000000000..7aa28bf54ee9d7c1e019108ca04be517541be232 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.xy; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/2de144c76928883d92f223216c54e72a.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag new file mode 100644 index 0000000000000000000000000000000000000000..a4d6f4fa5502928c29e2c34c6181ac4be74b48b4 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.frag @@ -0,0 +1,145 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f4(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f2(thread const float& _p0, thread const float& _p1) +{ + float2 _106 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t5 = _106 + float2(dot(_106, _106.yx + float2(22.5410003662109375))); + return fract((_t5.x + _t5.y) * _t5.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t4 = float2(1.0); + if (edgeMode == 0) + { + _t4.x = step(0.0, _p0) * step(_p0, 1.0); + _t4.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t4; +} + +static inline __attribute__((always_inline)) +float4 _f3(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _136 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.19900000095367431640625; + float param_1 = _p0 * uv0.y; + float2 _166 = uv0 + (_136 * float2(_p0 + ((dither * _p1) * _f2(param, param_1)), 0.0)); + float2 _t7 = _166; + float param_2 = (_p0 + uv0.x) + 0.676999986171722412109375; + float param_3 = _p0 * uv0.y; + float2 _191 = uv0 - (_136 * float2(_p0 + ((dither * _p1) * _f2(param_2, param_3)), 0.0)); + float2 _t8 = _191; + float param_4 = _t7.x; + float param_5 = _t8.x; + float2 _t9 = _f1(param_4, param_5, edgeMode); + return (inputTexture.sample(inputTextureSmplr, _166) * _t9.x) + (inputTexture.sample(inputTextureSmplr, _191) * _t9.y); +} + +static inline __attribute__((always_inline)) +float4 _f5(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t10 = float4(1.0); + float4 _t11 = float4(0.0); + float _251 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t15 = 1.0; + for (float _t16 = 1.0; _t16 <= 128.0; _t16 += 1.0) + { + if (_t15 > 128.0) + { + break; + } + bool _270 = _t15 <= ColorRadius.x; + bool _278; + if (!_270) + { + _278 = _t15 <= ColorRadius.y; + } + else + { + _278 = _270; + } + bool _286; + if (!_278) + { + _286 = _t15 <= ColorRadius.z; + } + else + { + _286 = _278; + } + if ((_t15 > (MaxRadius * _251)) || (!_286)) + { + break; + } + float param = _t15; + float param_1 = ColorSigma.x; + _t11.x = step(_t15, ColorRadius.x) * _f4(param, param_1); + float param_2 = _t15; + float param_3 = ColorSigma.y; + _t11.y = step(_t15, ColorRadius.y) * _f4(param_2, param_3); + float param_4 = _t15; + float param_5 = ColorSigma.z; + _t11.z = step(_t15, ColorRadius.z) * _f4(param_4, param_5); + float param_6 = _t15; + float param_7 = ColorSigma.w; + _t11.w = step(_t15, ColorRadius.w) * _f4(param_6, param_7); + float param_8 = _t15; + float param_9 = _251; + _p0 += (_f3(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t11); + _t10 += (_t11 * 2.0); + _t15 += _251; + } + _p0 /= _t10; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f0(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float4 _381 = _f5(param, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_1 = _381.zw; + out.o_fragColor = _f0(param_1); + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/74372f1bcf355acef84cc449f41b07ed.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag new file mode 100644 index 0000000000000000000000000000000000000000..57f8e24dbd343dcc8a14f4f35147e08fa9e92387 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(0.0, 0.0, _f0(param_6)) * _t11.x) + (float4(0.0, 0.0, _f0(param_7)) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.z = _411.x; + _t19.w = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.zw; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/c84292538f7734d765bf150adc6f4fe7.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag new file mode 100644 index 0000000000000000000000000000000000000000..67ef99766e7b248bad22966aabbae078f71dc487 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.frag @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + float glowFromAlpha; + float threshold; + float3 color; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float& _p0, thread const float& _p1) +{ + float _17; + if (_p0 <= _p1) + { + _17 = 0.0; + } + else + { + _17 = (_p0 - _p1) / (1.0 - _p1); + } + return _17; +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _44 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t0 = _44; + float3 _53 = mix(_44.xyz, float3(1.0), float3(buffer.glowFromAlpha)); + _t0.x = _53.x; + _t0.y = _53.y; + _t0.z = _53.z; + float param = _t0.x; + float param_1 = buffer.threshold + buffer.color.x; + float param_2 = _t0.y; + float param_3 = buffer.threshold + buffer.color.y; + float param_4 = _t0.z; + float param_5 = buffer.threshold + buffer.color.z; + out.o_fragColor = _t0 * (((_f0(param, param_1) + _f0(param_2, param_3)) + _f0(param_4, param_5)) / fast::max((_t0.x + _t0.y) + _t0.z, 9.9999999747524270787835121154785e-07)); + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d238188dfb368fd818a911f5e9918d7f.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag new file mode 100644 index 0000000000000000000000000000000000000000..05877994fb80da04a550a8f44f75c386728f2aeb --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.frag @@ -0,0 +1,158 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int edgeMode; + float4 u_ScreenParams; + float dither; + float4 ColorRadius; + float MaxRadius; + float4 ColorSigma; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 uv0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float2 _f0(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +static inline __attribute__((always_inline)) +float _f5(thread const float& _p0, thread const float& _p1) +{ + return exp((-(_p0 * _p0)) / _p1); +} + +static inline __attribute__((always_inline)) +float _f3(thread const float& _p0, thread const float& _p1) +{ + float2 _131 = fract(float2(_p0, _p1) * 13.5170001983642578125); + float2 _t7 = _131 + float2(dot(_131, _131.yx + float2(22.5410003662109375))); + return fract((_t7.x + _t7.y) * _t7.y) - 0.5; +} + +static inline __attribute__((always_inline)) +float2 _f2(thread const float& _p0, thread const float& _p1, constant int& edgeMode) +{ + float2 _t6 = float2(1.0); + if (edgeMode == 0) + { + _t6.x = step(0.0, _p0) * step(_p0, 1.0); + _t6.y = step(0.0, _p1) * step(_p1, 1.0); + } + return _t6; +} + +static inline __attribute__((always_inline)) +float4 _f4(thread const float& _p0, thread const float& _p1, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr) +{ + float2 _161 = float2(1.0) / u_ScreenParams.xy; + float param = (_p0 + uv0.x) + 0.22300000488758087158203125; + float param_1 = _p0 * uv0.y; + float2 _191 = uv0 + (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param, param_1)))); + float2 _t9 = _191; + float param_2 = (_p0 + uv0.x) + 0.5690000057220458984375; + float param_3 = _p0 * uv0.y; + float2 _216 = uv0 - (_161 * float2(0.0, _p0 + ((dither * _p1) * _f3(param_2, param_3)))); + float2 _t10 = _216; + float param_4 = _t9.y; + float param_5 = _t10.y; + float2 _t11 = _f2(param_4, param_5, edgeMode); + float4 param_6 = inputTexture.sample(inputTextureSmplr, _191); + float4 param_7 = inputTexture.sample(inputTextureSmplr, _216); + return (float4(_f0(param_6), 0.0, 0.0) * _t11.x) + (float4(_f0(param_7), 0.0, 0.0) * _t11.y); +} + +static inline __attribute__((always_inline)) +float4 _f6(thread float4& _p0, constant int& edgeMode, constant float4& u_ScreenParams, thread float2& uv0, constant float& dither, texture2d inputTexture, sampler inputTextureSmplr, constant float4& ColorRadius, constant float& MaxRadius, constant float4& ColorSigma) +{ + float4 _t12 = float4(1.0); + float4 _t13 = float4(0.0); + float _285 = fast::max(1.0, fast::max(fast::max(ColorRadius.x, ColorRadius.y), ColorRadius.z) / MaxRadius); + float _t17 = 1.0; + for (float _t18 = 1.0; _t18 <= 128.0; _t18 += 1.0) + { + if (_t17 > 128.0) + { + break; + } + bool _304 = _t17 <= ColorRadius.x; + bool _312; + if (!_304) + { + _312 = _t17 <= ColorRadius.y; + } + else + { + _312 = _304; + } + bool _320; + if (!_312) + { + _320 = _t17 <= ColorRadius.z; + } + else + { + _320 = _312; + } + if ((_t17 > (MaxRadius * _285)) || (!_320)) + { + break; + } + float param = _t17; + float param_1 = ColorSigma.x; + _t13.x = step(_t17, ColorRadius.x) * _f5(param, param_1); + float param_2 = _t17; + float param_3 = ColorSigma.y; + _t13.y = step(_t17, ColorRadius.y) * _f5(param_2, param_3); + float param_4 = _t17; + float param_5 = ColorSigma.z; + _t13.z = step(_t17, ColorRadius.z) * _f5(param_4, param_5); + float param_6 = _t17; + float param_7 = ColorSigma.w; + _t13.w = step(_t17, ColorRadius.w) * _f5(param_6, param_7); + float param_8 = _t17; + float param_9 = _285; + _p0 += (_f4(param_8, param_9, edgeMode, u_ScreenParams, uv0, dither, inputTexture, inputTextureSmplr) * _t13); + _t12 += (_t13 * 2.0); + _t17 += _285; + } + _p0 /= _t12; + return _p0; +} + +static inline __attribute__((always_inline)) +float4 _f1(thread const float2& _p0) +{ + return float4(floor(_p0.x * 255.0) / 255.0, fract(_p0.x * 255.0), floor(_p0.y * 255.0) / 255.0, fract(_p0.y * 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], sampler inputTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + float4 _t19 = float4(0.0); + float4 param = inputTexture.sample(inputTextureSmplr, in.uv0); + float2 _411 = _f0(param); + _t19.x = _411.x; + _t19.y = _411.y; + float4 param_1 = _t19; + float4 _420 = _f6(param_1, buffer.edgeMode, buffer.u_ScreenParams, in.uv0, buffer.dither, inputTexture, inputTextureSmplr, buffer.ColorRadius, buffer.MaxRadius, buffer.ColorSigma); + float2 param_2 = _420.xy; + out.o_fragColor = _f1(param_2); + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert new file mode 100644 index 0000000000000000000000000000000000000000..44338d76b536fae713d3b8d0b5e32b98c08390af --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/d7a6180743adc330a3f86bd8721f6046.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 uv0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.uv0 = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag new file mode 100644 index 0000000000000000000000000000000000000000..d706447961880fc0db3256c104888585f825f5e2 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.frag @@ -0,0 +1,155 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct buffer_t +{ + int hasBgTex; + float4 u_ScreenParams; + float2 bgTextureSize; + float sourceOpacity; + float bgBrightness; + float3 GlowColor; + float brightness; + float glowUnderSource; + float lightBackground; + int combine; +}; + +struct main0_out +{ + float4 o_fragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 v_uv [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +float _f0(thread const float2& _p0) +{ + return ((step(0.0, _p0.x) * step(_p0.x, 1.0)) * step(0.0, _p0.y)) * step(_p0.y, 1.0); +} + +static inline __attribute__((always_inline)) +float2 _f1(thread const float4& _p0) +{ + return float2(_p0.x + (_p0.y / 255.0), _p0.z + (_p0.w / 255.0)); +} + +fragment main0_out main0(main0_in in [[stage_in]], constant buffer_t& buffer, texture2d inputTexture [[texture(0)]], texture2d bgTexture [[texture(1)]], texture2d blurTexture1 [[texture(2)]], texture2d blurTexture2 [[texture(3)]], sampler inputTextureSmplr [[sampler(0)]], sampler bgTextureSmplr [[sampler(1)]], sampler blurTexture1Smplr [[sampler(2)]], sampler blurTexture2Smplr [[sampler(3)]]) +{ + main0_out out = {}; + float4 _73 = inputTexture.sample(inputTextureSmplr, in.v_uv); + float4 _t2 = _73; + float4 _t3 = float4(0.0, 0.0, 0.0, _t2.w); + if (buffer.hasBgTex > 0) + { + float2 _t4 = in.v_uv; + _t4.y = 1.0 - _t4.y; + _t4 -= float2(0.5); + _t4.x *= (buffer.u_ScreenParams.x / buffer.bgTextureSize.x); + _t4.y *= (buffer.u_ScreenParams.y / buffer.bgTextureSize.y); + float2 _120 = _t4; + float2 _122 = _120 + float2(0.5); + _t4 = _122; + float2 param = _122; + _t3 = bgTexture.sample(bgTextureSmplr, _122) * _f0(param); + } + float4 _135 = float4(buffer.sourceOpacity); + _t3 = mix(_t3, _73, _135) * buffer.bgBrightness; + float4 param_1 = blurTexture1.sample(blurTexture1Smplr, in.v_uv); + float4 param_2 = blurTexture2.sample(blurTexture2Smplr, in.v_uv); + float4 _158 = float4(_f1(param_1), _f1(param_2)); + float4 _t5 = _158; + float3 _165 = _158.xyz * buffer.GlowColor; + _t5.x = _165.x; + _t5.y = _165.y; + _t5.z = _165.z; + float4 _174 = _t5; + float4 _175 = _174 * buffer.brightness; + _t5 = _175; + float4 _192 = mix(_175, mix(_175, _73, _135), float4(buffer.glowUnderSource)) * (1.0 - buffer.lightBackground); + float4 _t6 = _192; + _t3 = fast::clamp(_t3, float4(0.0), float4(1.0)); + float4 _t8 = _73; + if (buffer.combine == 1) + { + float3 _219 = _192.xyz + _t3.xyz; + _t8.x = _219.x; + _t8.y = _219.y; + _t8.z = _219.z; + } + else + { + if (buffer.combine == 2) + { + float3 _236 = _t3.xyz * _192.xyz; + _t8.x = _236.x; + _t8.y = _236.y; + _t8.z = _236.z; + } + else + { + if (buffer.combine == 3) + { + float3 _254 = abs(_192.xyz - _t3.xyz); + _t8.x = _254.x; + _t8.y = _254.y; + _t8.z = _254.z; + } + else + { + if (buffer.combine == 4) + { + float _270; + if (_t3.x < 0.5) + { + _270 = (2.0 * _t3.x) * _t6.x; + } + else + { + _270 = 1.0 - ((2.0 * (1.0 - _t3.x)) * (1.0 - _t6.x)); + } + float _294; + if (_t3.y < 0.5) + { + _294 = (2.0 * _t3.y) * _t6.y; + } + else + { + _294 = 1.0 - ((2.0 * (1.0 - _t3.y)) * (1.0 - _t6.y)); + } + float _317; + if (_t3.z < 0.5) + { + _317 = (2.0 * _t3.z) * _t6.z; + } + else + { + _317 = 1.0 - ((2.0 * (1.0 - _t3.z)) * (1.0 - _t6.z)); + } + float3 _337 = float3(_270, _294, _317); + _t8.x = _337.x; + _t8.y = _337.y; + _t8.z = _337.z; + } + else + { + float3 _355 = float3(1.0) - ((float3(1.0) - _t3.xyz) * (float3(1.0) - _192.xyz)); + _t8.x = _355.x; + _t8.y = _355.y; + _t8.z = _355.z; + } + } + } + } + _t8.w = _t5.w + ((1.0 - _t5.w) * _t2.w); + out.o_fragColor = _t8; + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert new file mode 100644 index 0000000000000000000000000000000000000000..14382fdd95cfb9cb90be1af7e80cb5aa28c68550 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/effects/LumiSGlow/xshader/shaderLib/shaderMetal/e13c388269ee5936c2ccd20a23e7d405.vert @@ -0,0 +1,26 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 v_uv [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float2 a_position [[attribute(0)]]; + float2 a_texcoord0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position = sign(float4(in.a_position, 0.0, 1.0)); + out.v_uv = in.a_texcoord0; + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + return out; +} + diff --git a/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/AETools.lua b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/AETools.lua new file mode 100644 index 0000000000000000000000000000000000000000..07ad317cd97ebb4ef6a4b329cdda5e775c5c2b2c --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/AETools.lua @@ -0,0 +1,273 @@ +local AETools = AETools or {} +AETools.__index = AETools + +-- AE PropertyValueType +local ThreeD_SPATIAL = 6413 +local ThreeD = 6414 +local TwoD_SPATIAL = 6415 +local TwoD = 6416 +local OneD = 6417 + +local function deepcopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + -- setmetatable(copy, deepcopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + +function AETools.new(attrs) + if attrs == nil then return nil end + + local self = setmetatable({}, AETools) + self.attrs = attrs + + local max_frame = 0 + local min_frame = 100000 + for _,v in pairs(attrs) do + for i = 1, #v do + local content = v[i] + local cur_frame_min = content[2][1] + local cur_frame_max = content[2][2] + max_frame = math.max(cur_frame_max, max_frame) + min_frame = math.min(cur_frame_min, min_frame) + + if content[4] ~= nil + and content[5] ~= nil + and (content[4][1] == ThreeD_SPATIAL or content[4][1] == TwoD_SPATIAL) + and content[5][1] == 0 + then + local p0 = content[3][1] + local totalLen = 0 + local lenInfo = {} + lenInfo[0] = 0 + for test=1,200,1 do + local coord = self._cubicBezier3D(content[3][1], content[3][3], content[3][4], content[3][2], test/200) + local length = 0 + if #p0 >= 3 then + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])+(coord[3]-p0[3])*(coord[3]-p0[3])) + else + length = math.sqrt((coord[1]-p0[1])*(coord[1]-p0[1])+(coord[2]-p0[2])*(coord[2]-p0[2])) + end + p0 = coord + totalLen = totalLen + length + lenInfo[test] = totalLen + -- print(test/200 .. " coord: "..coord[1].." - "..coord[2]) + end + for test=1,200,1 do + lenInfo[test] = lenInfo[test]/(lenInfo[200]+0.000001) + -- print(test/200 .. " "..lenInfo[test]) + end + content['lenInfo'] = lenInfo + end + end + end + + self.all_frame = max_frame - min_frame + self.min_frame = min_frame + + return self +end + +function AETools:CurFrame(_p) + local frame = math.floor(_p*self.all_frame) + return frame + self.min_frame +end + +function AETools:AllFrame(_p) + return self.all_frame +end + +function AETools._remap01(a,b,x) + if x < a then return 0 end + if x > b then return 1 end + return (x-a)/(b-a) +end + +function AETools._cubicBezier(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + return { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + } +end + +function AETools._cubicBezier3D(p1, p2, p3, p4, t) + local t2 = t * t + local t3 = t2 * t + local _t = 1 - t + local _t2 = _t * _t + local _t3 = _t2 * _t + local value = { + p1[1] * _t3 + 3 * p2[1] * _t2 * t + 3 * p3[1] * _t * t2 + p4[1] * t3, + p1[2] * _t3 + 3 * p2[2] * _t2 * t + 3 * p3[2] * _t * t2 + p4[2] * t3, + 0, + } + if #p1 >= 3 then + value[3] = p1[3] * _t3 + 3 * p2[3] * _t2 * t + 3 * p3[3] * _t * t2 + p4[3] * t3 + end + return value +end + +function AETools:_cubicBezierSpatial(lenInfo, p1, p2, p3, p4, t) + local p = 0 + if t <= 0 then + p = 0 + elseif t >= 1 then + p = 1 + else + local ts = 199 + local te = 200 + for i=1,200,1 do + if lenInfo[i] >= t then + te = i + ts = i-1 + break + end + end + p = ts/200. + 0.005*(t-lenInfo[ts])/(lenInfo[te]-lenInfo[ts]+0.000001) + end + return self._cubicBezier3D(p1, p2, p3, p4, p) +end + +function AETools:_cubicBezier01(_bezier_val, p, y_len) + local x = self:_getBezier01X(_bezier_val, p, y_len) + return self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + x + )[2] +end + +function AETools:AllFrame() + return self.all_frame +end + +function AETools:_getBezier01X(_bezier_val, x, y_len) + local ts = 0 + local te = 1 + -- divide and conque + local times = 1 + repeat + local tm = (ts+te)*0.5 + local value = self._cubicBezier( + {0,0}, + {_bezier_val[1], _bezier_val[2]}, + {_bezier_val[3], _bezier_val[4]}, + {1, y_len}, + tm) + if(value[1]>x) then + te = tm + else + ts = tm + end + times = times +1 + until(te-ts < 0.001 and times < 50) + + return (te+ts)*0.5 +end + +function AETools._mix(a, b, x, type) + if type == 1 then + return a * (1-x) + b * x + end + return a + x +end + +function AETools:GetVal(_name, _progress) + local content = self.attrs[_name] + if content == nil then + return nil + end + + -- local cur_frame = _progress * self.all_frame + self.min_frame + local cur_frame = _progress + + for i = 1, #content do + local info = content[i] + local start_frame = info[2][1] + local end_frame = info[2][2] + if cur_frame >= start_frame and cur_frame < end_frame then + local cur_progress = self._remap01(start_frame, end_frame, cur_frame) + local bezier = info[1] + local value_range = info[3] + local y_len = 1 + if (value_range[2][1] == value_range[1][1] and info[5] and info[5][1]==0 and #(value_range[1])==1) then + y_len = 0 + end + + if info[5] and info[5][1] == 2 then + return deepcopy(info[3][1]) + end + + if #bezier > 4 then + -- currently scale attrs contains more than 4 bezier values + local res = {} + for k = 1, 3 do + local cur_bezier = {bezier[k], bezier[k+3], bezier[k+3*2], bezier[k+3*3]} + local p = self:_cubicBezier01(cur_bezier, cur_progress, y_len) + res[k] = self._mix(value_range[1][k], value_range[2][k], p, y_len) + end + return res + + else + local p = self:_cubicBezier01(bezier, cur_progress, y_len) + if info[4] ~= nil + and info[5] ~= nil + and (info[4][1] == ThreeD_SPATIAL or info[4][1] == TwoD_SPATIAL) + and info[5][1] == 0 + then + local coord = self:_cubicBezierSpatial( + info['lenInfo'], + value_range[1], + value_range[3], + value_range[4], + value_range[2], + p + ) + if info[4][1] == TwoD_SPATIAL then + return {coord[1], coord[2]} + end + return coord + end + + if type(value_range[1]) == "table" then + local res = {} + for j = 1, #value_range[1] do + res[j] = self._mix(value_range[1][j], value_range[2][j], p, y_len) + end + return res + end + return self._mix(value_range[1], value_range[2], p, y_len) + end + end + end + + local first_info = content[1] + local start_frame = first_info[2][1] + if cur_frame=end_frame then + return deepcopy(last_info[3][2]) + end + + return nil +end + +return AETools diff --git a/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiEffect.lua b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiEffect.lua new file mode 100644 index 0000000000000000000000000000000000000000..bee4c14190a8231d06c80826ceaa131067ca8ad2 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiEffect.lua @@ -0,0 +1,32 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiEffect = LumiEffect or {} +LumiEffect.__index = LumiEffect +---@class LumiEffect : ScriptComponent + +function LumiEffect.new(construct, ...) + local self = setmetatable({}, LumiEffect) + + self.__lumi_type = "lumi_effect" + self.__lumi_rt_pingpong_type = "custom" + + return self +end + +function LumiEffect:constructor() +end + +function LumiEffect:onStart(comp) +end + +function LumiEffect:onDestroy(comp) +end + +function LumiEffect:updateMaterials(comp, deltaTime) +end + +function LumiEffect:onUpdate(comp, deltaTime) +end + +exports.LumiEffect = LumiEffect +return exports diff --git a/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiExportData.lua b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiExportData.lua new file mode 100644 index 0000000000000000000000000000000000000000..fb8d2fd4e40f28fc338743168286ed9a5e94a8ee --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiExportData.lua @@ -0,0 +1,388 @@ +local data = {} + +local ae_compDurations = {0, 2} +data.ae_compDurations = ae_compDurations + +local ae_effectType = 'transition' +data.ae_effectType = ae_effectType + +local ae_transitionInputIndex = { + {'LumiSGlow_102-effect0', 'InputTex', 0}, + {'LumiSGlow_103-effect0', 'InputTex', 1}, +} +data.ae_transitionInputIndex = ae_transitionInputIndex + +local ae_durations = { + ['LumiSGlow_102-effect0'] = { + ['nodeDuration'] = {{0, 0.6}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 0.6}, }, + }, + }, + ['LumiGaussianBlur_102-effect1'] = { + ['nodeDuration'] = {{0, 0.6}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 0.6}, }, + }, + }, + ['LumiSGlow_103-effect0'] = { + ['nodeDuration'] = {{0.6, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.6, 2}, }, + }, + }, + ['LumiGaussianBlur_103-effect1'] = { + ['nodeDuration'] = {{0.6, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0.6, 2}, }, + }, + }, + ['LumiLayer_102-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 0.6}, }, + ['baseTex'] = {{0.6, 2}, }, + }, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['seqTex_1_1'] = {{0, 2}, }, + ['seqTex_9_16'] = {{0, 2}, }, + ['seqTex_16_9'] = {{0, 2}, }, + }, + }, + ['LumiLayer_101-trs-blend'] = { + ['nodeDuration'] = {{0, 2}, }, + ['texDuration'] = { + ['InputTex'] = {{0, 2}, }, + ['baseTex'] = {{0, 2}, }, + }, + }, +} +data.ae_durations = ae_durations + +local ae_attribute = { + ['LumiSGlow_102-effect0'] = { + ['brightness'] = 0, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_102-effect1'] = { + ['blurIntensity'] = 0, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiSGlow_103-effect0'] = { + ['brightness'] = 10, + ['glowColor'] = Amaz.Color(1, 1, 1, 1), + ['threshold'] = 0.5, + ['thresholdAddColor'] = Amaz.Color(0, 0, 0, 1), + ['glowWidth'] = 0.1, + ['widthX'] = 1, + ['widthY'] = 1, + ['widthRed'] = 1, + ['widthGreen'] = 1.20000004768372, + ['widthBlue'] = 1.39999997615814, + ['show'] = 0, + ['combine'] = 0, + ['edgeMode'] = 1, + ['glowFromAlpha'] = 0, + ['glowUnderSource'] = 0, + ['sourceOpacity'] = 1, + ['dither'] = 1, + ['quality'] = 0.2, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiGaussianBlur_103-effect1'] = { + ['blurIntensity'] = 30, + ['quality'] = 0.5, + ['spaceDither'] = 0, + ['horizontalStrength'] = 1, + ['verticalStrength'] = 1, + ['blurDirection'] = 0, + ['borderType'] = 0, + ['blurAlpha'] = true, + ['inverseGammaCorrection'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_102-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = false, + ['layerType'] = 'Precomp', + ['blendMode'] = 0, + }, + ['LumiAnimSeqLoadAndCrop_101-effect0'] = { + ['specify_1_1'] = true, + ['animSeqType_1_1'] = 0, + ['cropType_1_1'] = 1, + ['edgeType_1_1'] = 0, + ['enableVideoAlphaBlend_1_1'] = true, + ['pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1_1'] = 0, + ['scale_1_1'] = 1, + ['opacity_1_1'] = 1, + ['speed_1_1'] = 1, + ['playMode_1_1'] = 0, + ['specify_9_16'] = true, + ['animSeqType_9_16'] = 0, + ['cropType_9_16'] = 1, + ['edgeType_9_16'] = 0, + ['enableVideoAlphaBlend_9_16'] = true, + ['pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_9_16'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_9_16'] = 0, + ['scale_9_16'] = 1, + ['opacity_9_16'] = 1, + ['speed_9_16'] = 1, + ['playMode_9_16'] = 0, + ['specify_16_9'] = true, + ['animSeqType_16_9'] = 0, + ['cropType_16_9'] = 1, + ['edgeType_16_9'] = 0, + ['enableVideoAlphaBlend_16_9'] = true, + ['pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_16_9'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_16_9'] = 0, + ['scale_16_9'] = 1, + ['opacity_16_9'] = 1, + ['speed_16_9'] = 1, + ['playMode_16_9'] = 0, + ['specify_5.8'] = false, + ['animSeqType_5.8'] = 2, + ['cropType_5.8'] = 1, + ['edgeType_5.8'] = 0, + ['enableVideoAlphaBlend_5.8'] = false, + ['pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_5.8'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_5.8'] = 0, + ['scale_5.8'] = 1, + ['opacity_5.8'] = 1, + ['speed_5.8'] = 1, + ['playMode_5.8'] = 0, + ['specify_2_1'] = false, + ['animSeqType_2_1'] = 2, + ['cropType_2_1'] = 1, + ['edgeType_2_1'] = 0, + ['enableVideoAlphaBlend_2_1'] = false, + ['pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2_1'] = 0, + ['scale_2_1'] = 1, + ['opacity_2_1'] = 1, + ['speed_2_1'] = 1, + ['playMode_2_1'] = 0, + ['specify_3_4'] = false, + ['animSeqType_3_4'] = 2, + ['cropType_3_4'] = 1, + ['edgeType_3_4'] = 0, + ['enableVideoAlphaBlend_3_4'] = false, + ['pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_3_4'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_3_4'] = 0, + ['scale_3_4'] = 1, + ['opacity_3_4'] = 1, + ['speed_3_4'] = 1, + ['playMode_3_4'] = 0, + ['specify_4_3'] = false, + ['animSeqType_4_3'] = 2, + ['cropType_4_3'] = 1, + ['edgeType_4_3'] = 0, + ['enableVideoAlphaBlend_4_3'] = false, + ['pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_4_3'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_4_3'] = 0, + ['scale_4_3'] = 1, + ['opacity_4_3'] = 1, + ['speed_4_3'] = 1, + ['playMode_4_3'] = 0, + ['specify_1.85_1'] = false, + ['animSeqType_1.85_1'] = 2, + ['cropType_1.85_1'] = 1, + ['edgeType_1.85_1'] = 0, + ['enableVideoAlphaBlend_1.85_1'] = false, + ['pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_1.85_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_1.85_1'] = 0, + ['scale_1.85_1'] = 1, + ['opacity_1.85_1'] = 1, + ['speed_1.85_1'] = 1, + ['playMode_1.85_1'] = 0, + ['specify_2.35_1'] = false, + ['animSeqType_2.35_1'] = 2, + ['cropType_2.35_1'] = 1, + ['edgeType_2.35_1'] = 0, + ['enableVideoAlphaBlend_2.35_1'] = false, + ['pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_pivot_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['ae_pre_position_2.35_1'] = Amaz.Vector2f(0.5, 0.5), + ['rotation_2.35_1'] = 0, + ['scale_2.35_1'] = 1, + ['opacity_2.35_1'] = 1, + ['speed_2.35_1'] = 1, + ['playMode_2.35_1'] = 0, + ['globalRotation'] = 0, + ['globalScale'] = 1, + ['globalOpacity'] = 1, + ['globalSpeed'] = 1, + ['lite_mode'] = true, + ['AEDesignSize'] = Amaz.Vector2f(1080, 1080), + }, + ['LumiLayer_101-trs-blend'] = { + ['hasBlend'] = true, + ['hasMatte'] = false, + ['hasTransform'] = true, + ['layerType'] = 'Solid', + ['anchorPoint'] = Amaz.Vector3f(540, 540, 0), + ['position'] = Amaz.Vector3f(540, 540, 0), + ['scale'] = Amaz.Vector3f(100, 100, 100), + ['orientation'] = Amaz.Vector3f(0, 0, 0), + ['xRotation'] = 0, + ['yRotation'] = 0, + ['rotation'] = 0, + ['opacity'] = 0, + ['active_cam_fovx'] = 39.6, + ['compositeSize'] = Amaz.Vector2f(1080, 1080), + ['layerSize'] = Amaz.Vector2f(1080, 1080), + ['mirrorEdge'] = false, + ['blendMode'] = 0, + }, +} +data.ae_attribute = ae_attribute + +local ae_keyframes = { + ['LumiSGlow_102-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.366667, 0.6, }, + {{0, }, {10, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_102-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.366667, 0.6, }, + {{0, }, {30, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiSGlow_103-effect0#brightness#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.6, 1.033333, }, + {{10, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiGaussianBlur_103-effect1#blurIntensity#number'] = +{ + { + {0.33333333, 0, 0.66666667, 1, }, + {0.6, 1.033333, }, + {{30, }, {0, }, }, + {6417, }, + {0, }, + }, +}, + ['LumiAnimSeqLoadAndCrop_101-effect0#seqTime#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 2, }, + {{0, }, {2, }, }, + {6417, }, + {1, }, + }, +}, + ['LumiLayer_101-trs-blend#opacity#number'] = +{ + { + {0.166666667, 0.166666667, 0.833333333, 0.833333333, }, + {0, 0.166667, }, + {{0, }, {100, }, }, + {6417, }, + {1, }, + }, +}, +} +data.ae_keyframes = ae_keyframes + +local ae_reverseKeyframes = false +data.ae_reverseKeyframes = ae_reverseKeyframes + +local ae_sliderInfos = { +} +data.ae_sliderInfos = ae_sliderInfos + +local ae_fadeinInfos = { + time = 0, + infos = { + } +} +data.ae_fadeinInfos = ae_fadeinInfos + +local ae_fadeoutInfos = { + time = 0, + infos = { + } +} +data.ae_fadeoutInfos = ae_fadeoutInfos + +local ae_animationInfos = { + animationMode = 0, + loopStart = 0, + speedInfo = {1, 0, 1, }, +} +data.ae_animationInfos = ae_animationInfos + +return data diff --git a/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiManager.lua b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiManager.lua new file mode 100644 index 0000000000000000000000000000000000000000..5c1441a2b25ba15d229ef75715d3b45463651801 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiManager.lua @@ -0,0 +1,553 @@ +local isEditor = (Amaz.Macros and Amaz.Macros.EditorSDK) and true or false +local exports = exports or {} +local LumiManager = LumiManager or {} +LumiManager.__index = LumiManager +---@class LumiManager : ScriptComponent +---@field debugTime number [UI(Range={0, 6}, Drag)] +---@field autoPlay boolean +---@field lumiEffectRoot Transform +---@field start_render_layer int +---@field start_render_order int + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +local EffectType = { + Effect = 'effect', + Transition = 'transition', + VideoAnimation = 'videoAnimation', + EffectXT = 'xtEffect', + FilterXT = 'xtFilter', +} + +local AnimationMode = { + Once = 0, + Loop = 1, + StretchOnce = 2, + StretchLoop = 3, +} + +local function clamp(val, min, max) + return math.min(math.max(val, min), max) +end + +local function remap(value, srcMin, srcMax, dstMin, dstMax) + return dstMin + (value - srcMin) * (dstMax - dstMin) / (srcMax - srcMin) +end + +local function handleAllEntityBySingleParent(_trans, func, ...) + if _trans.children:size() > 0 then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i - 1) + handleAllEntityBySingleParent(child, func, ...) + end + end + func(_trans, ...) +end + +local function intervalIntersection(intervals1, intervals2) + local result = {} + local i = 1 + local j = 1 + + while i <= #intervals1 and j <= #intervals2 do + local start1 = intervals1[i][1] + local end1 = intervals1[i][2] + local start2 = intervals2[j][1] + local end2 = intervals2[j][2] + + local start = math.max(start1, start2) + local end_ = math.min(end1, end2) + + if start <= end_ then + table.insert(result, {start, end_}) + end + if end1 < end2 then + i = i + 1 + else + j = j + 1 + end + end + return result +end + +function LumiManager.new(construct, ...) + local self = setmetatable({}, LumiManager) + + self.lumiEffectRoot = nil + self.start_render_layer = 1 + self.start_render_order = 1 + + self.InputTex = nil + self.OutputTex = nil + self.PingPongTex = nil + + self.startTime = 0.0 + self.endTime = 6.0 + self.curTime = 0.0 + + self.speed = 1.0 + self.animationMode = AnimationMode.Once + self.autoPlay = true + self.debugTime = 0.0 + + -- for XT + self.cameraStartTime = 0 + self.lastCycle = -1 + + return self +end + +function LumiManager:getKeyframeAeTime(aeTime) + if self.isReverseKeyframes ~= true then + return aeTime + end + return self.compDurations[1] + self.compDurations[2] - aeTime +end + +function LumiManager:onStart(comp) + self.entity = comp.entity + + self.lumi_obj_extension = includeRelativePath("LumiObjectExtension") + self.lumi_obj = nil + + self.keyframes = nil + self.durations = nil + self.params = nil + self.compDurations = {0, 6} + self.animationInfos = 0 + self.sliderInfos = {} + self.fadeinInfos = {} + self.fadeoutInfos = {} + self.effectType = "effect" + self.transitionInputIndex = {} + + self.LumiParamsSetter = includeRelativePath("LumiParamsSetter") + local ae_export_data = includeRelativePath("LumiExportData") + if ae_export_data then + if ae_export_data.ae_keyframes then + local ae_tools = includeRelativePath("AETools") + if ae_tools then + self.keyframes = ae_tools.new(ae_export_data.ae_keyframes) + end + end + if ae_export_data.ae_reverseKeyframes ~= nil then + self.isReverseKeyframes = ae_export_data.ae_reverseKeyframes + end + if ae_export_data.ae_durations ~= nil then + self.durations = ae_export_data.ae_durations + end + if ae_export_data.ae_attribute ~= nil then + self.params = ae_export_data.ae_attribute + end + if ae_export_data.ae_compDurations ~= nil then + self.compDurations = ae_export_data.ae_compDurations + self.compDurations[2] = self.compDurations[2] + end + if ae_export_data.ae_animationInfos ~= nil then + self.animationInfos = ae_export_data.ae_animationInfos + self.animationMode = self.animationInfos.animationMode + self.loopStart = self.animationInfos.loopStart + self.speed = self.animationInfos.speedInfo[1] + end + if ae_export_data.ae_sliderInfos ~= nil then + self.sliderInfos = ae_export_data.ae_sliderInfos + end + if ae_export_data.ae_fadeinInfos ~= nil then + self.fadeinInfos = ae_export_data.ae_fadeinInfos + end + if ae_export_data.ae_fadeoutInfos ~= nil then + self.fadeoutInfos = ae_export_data.ae_fadeoutInfos + end + if ae_export_data.ae_effectType ~= nil then + self.effectType = ae_export_data.ae_effectType + end + if ae_export_data.ae_cameraMode ~= nil then + self.cameraMode = ae_export_data.ae_cameraMode + end + if ae_export_data.ae_transitionInputIndex ~= nil then + self.transitionInputIndex = ae_export_data.ae_transitionInputIndex + end + end + if self.LumiParamsSetter then + self.lumi_params_setter = self.LumiParamsSetter.new( + self, + self.params, + self.keyframes, + self.effectType, + self.sliderInfos, + self.fadeinInfos, + self.fadeoutInfos + ) + end + + if self.effectType == EffectType.VideoAnimation then + local baseEntity = self.entity:searchEntity('base') + local videoCamera = baseEntity:searchEntity('videoCamera'):getComponent('Camera') + local videoRenderer = baseEntity:searchEntity('video'):getComponent('MeshRenderer') + local modelCamera = baseEntity:searchEntity('modelCamera'):getComponent('Camera') + local modelRenderer = baseEntity:searchEntity('model'):searchEntity('quad'):getComponent('MeshRenderer') + local fxaaCamera = baseEntity:searchEntity('fxaaCamera'):getComponent('Camera') + local fxaaRenderer = baseEntity:searchEntity('fxaa'):getComponent('MeshRenderer') + local bgCamera = baseEntity:searchEntity('bgCamera'):getComponent('Camera') + local bgRenderer = baseEntity:searchEntity('bg'):getComponent('MeshRenderer') + local blendCamera = baseEntity:searchEntity('blendCamera'):getComponent('Camera') + local blendRenderer = baseEntity:searchEntity('blend'):getComponent('MeshRenderer') + self.videoAnimationCameraAndRenderer = { + { camera = videoCamera, renderer = videoRenderer }, + { camera = modelCamera, renderer = modelRenderer }, + { camera = fxaaCamera, renderer = fxaaRenderer }, + { camera = bgCamera, renderer = bgRenderer }, + { camera = blendCamera, renderer = blendRenderer }, + } + end +end + +function LumiManager:onDestroy(comp) + if self.lumiEffectRoot and self.lumi_obj_extension then + self.lumi_obj_extension.deregister(self.lumiEffectRoot.entity) + end + self.lumi_obj = nil + self.LumiParamsSetter = nil +end + +function LumiManager:getCameraCount() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return 0 + end + + self.lumi_obj = nil + self:ReRender() + + local cam_count = 0 + if self.lumi_obj then + cam_count = self.lumi_obj:getCameraCount() + Amaz.LOGI(AE_EFFECT_TAG, self.lumi_obj.entity.name .. " camera_count: " .. tostring(cam_count)) + end + return cam_count +end + +function LumiManager:ReRender() + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + -- re register + self.lumi_obj = nil + self:registerLumiObj(self.lumiEffectRoot, 1) + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'No lumi_obj register') + return + end + + -- change layer & order + self:updateCameraLayerAndOrder() + + -- change rt pingpong + self:updateRtPingpong() +end + +function LumiManager:registerLumiObj(_trans, _idx) + if _trans == nil then return end + local script_comp = _trans.entity:getComponent("ScriptComponent") + if script_comp then + local lua_obj = Amaz.ScriptUtils.getLuaObj(script_comp:getScript()) + if lua_obj then + self.lumi_obj_extension.deregister(_trans.entity) + self.lumi_obj = self.lumi_obj_extension.register(_trans.entity) + end + end +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str .. "0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiManager:updateCameraLayerAndOrder() + if self.lumi_obj then + local cur_start_layer, cur_start_order = self.lumi_obj:updateCameraLayerAndOrder(self.start_render_layer, self.start_render_order) + + if self.effectType == EffectType.VideoAnimation then + cur_start_layer = cur_start_layer + 10 + cur_start_order = cur_start_order + 10 + + for i = 1, #self.videoAnimationCameraAndRenderer do + local cameraAndRenderer = self.videoAnimationCameraAndRenderer[i] + local camera = cameraAndRenderer.camera + local renderer = cameraAndRenderer.renderer + camera.renderOrder = cur_start_order + _setLayer(camera, cur_start_layer) + renderer.entity.layer = cur_start_layer + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end +end + +function LumiManager:updateRtPingpong() + if self.lumi_obj then + self.lumi_obj:updateRt(self.InputTex, self.OutputTex, self.PingPongTex) + end +end + +function LumiManager:updateOutputRtSize() + if self.lumi_obj then + self.lumi_obj:updateOutputRtSize(self.width, self.height) + end +end + +function LumiManager:initVideoAnimationLua(comp) + local modelEntity = comp.entity:searchEntity("model") + if modelEntity then + local scriptComp = modelEntity:getComponent("ScriptComponent") + if scriptComp then + self.videoAnimationLua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + end + end +end + +function LumiManager:onUpdate(comp, deltaTime) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.durations and not self.isSetDuration then + for entityName, durationMap in pairs(self.durations) do + local isLumiLayer = string.sub(entityName, 1, string.len('LumiLayer')) == 'LumiLayer' + if isLumiLayer then + local texDuration = durationMap['texDuration'] + local srcDuration = texDuration['InputTex'] + local baseDuration = texDuration['baseTex'] + local maskDuration = texDuration['maskTex'] + if srcDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'srcDuration', srcDuration) + end + if baseDuration then + self.lumi_obj:setSubEffectAttr(entityName, 'baseDuration', baseDuration) + end + if maskDuration then + local matteDuration = intervalIntersection(maskDuration, srcDuration) + self.lumi_obj:setSubEffectAttr(entityName, 'matteDuration', matteDuration) + end + end + end + self.isSetDuration = true + end + + local w = Amaz.BuiltinObject.getInputTextureWidth() + local h = Amaz.BuiltinObject.getInputTextureHeight() + if self.InputTex then + w = self.InputTex.width + h = self.InputTex.height + end + if self.OutputTex and (self.OutputTex.width ~= w or self.OutputTex.height ~= h) then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid rt size, input: ' .. w .. 'x' .. h .. ', output: ' .. self.OutputTex.width .. 'x' .. self.OutputTex.height) + end + if self.width == nil or self.width ~= w or self.height == nil or self.height ~= h then + self.width = w + self.height = h + self:updateOutputRtSize() + end + + self.curTime = self.curTime + deltaTime + if isEditor then + self.curTime = self.curTime % self.endTime + end + local curTime = (self.curTime - self.startTime) * self.speed + self.startTime + local startTime = self.startTime + local endTime = (self.endTime - self.startTime) * self.speed + self.startTime + + if self.cameraMode then + if self.animationMode ~= AnimationMode.Loop then + Amaz.LOGE(AE_EFFECT_TAG, 'Camera mode is not support animationMode: ' .. tostring(self.animationMode)) + return + end + curTime = self.curTime - self.cameraStartTime + endTime = math.huge + elseif self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT then -- deprecated after 1810 in XT + startTime = 0 + if self.isVideo then + endTime = self.videoTime + else + endTime = 3 + end + end + + local aeTime = curTime; + local aeDuration = math.max(0.001, self.compDurations[2] - self.compDurations[1]) + if endTime < curTime then + aeTime = math.max(self.compDurations[1], self.compDurations[2] - (self.endTime - self.curTime)) + else + local lvDuration = math.max(0.001, endTime - startTime) + if self.animationMode == AnimationMode.Once then + aeTime = self.compDurations[1] + curTime - startTime + aeTime = math.min(aeTime, self.compDurations[2]) + elseif self.animationMode == AnimationMode.Loop then + if self.cameraMode then + local cycle = math.floor((curTime - startTime) / aeDuration) + if self.lastCycle ~= cycle then + self.lastCycle = cycle + comp.entity.scene:sendMessage(4999, 1, 0, '') + end + end + if math.floor((curTime - startTime) / aeDuration) < 1 then + aeTime = self.compDurations[1] + (curTime - startTime) % aeDuration + else + local curLoopStart = (self.loopStart - self.compDurations[1]) * self.speed + self.compDurations[1] + aeTime = self.loopStart + (curTime - startTime - curLoopStart) % (aeDuration - self.loopStart) + end + elseif self.animationMode == AnimationMode.StretchOnce then + aeTime = remap(curTime, startTime, self.endTime, self.compDurations[1], self.compDurations[2]) + aeTime = clamp(aeTime, self.compDurations[1], self.compDurations[2]) + elseif self.animationMode == AnimationMode.StretchLoop then + local newCurTime = startTime + (curTime - startTime) * self.speed % lvDuration + aeTime = remap(newCurTime, startTime, endTime, self.compDurations[1], self.compDurations[2]) + + if math.floor((curTime - startTime) * self.speed / lvDuration) >= 1 then + aeTime = self.compDurations[1] + (aeTime - self.compDurations[1]) % (self.compDurations[2] - self.loopStart) + self.loopStart + end + end + end + + if self.effectType == EffectType.Transition then + local input1 = Amaz.BuiltinObject.getUserTexture("#TransitionInput0") + local input2 = Amaz.BuiltinObject.getUserTexture("#TransitionInput1") + if input1 and input2 then + for index, transitionInputInfo in ipairs(self.transitionInputIndex) do + local entityName = transitionInputInfo[1] + local texName = transitionInputInfo[2] + local inputIndex = transitionInputInfo[3] + if inputIndex == 0 then + self.lumi_obj:setSubEffectAttr(entityName, texName, input1) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 0) + else + self.lumi_obj:setSubEffectAttr(entityName, texName, input2) + self.lumi_obj:setSubEffectAttr(entityName, 'algoSlot', 1) + end + end + aeTime = Amaz.Input.frameTimestamp * (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + end + elseif self.effectType == EffectType.VideoAnimation then + if self.videoAnimationLua == nil then + self:initVideoAnimationLua(comp) + end + if self.videoAnimationLua ~= nil then + aeTime = remap(self.videoAnimationLua.curTime, 0, self.videoAnimationLua.duration, self.compDurations[1], self.compDurations[2]) + end + end + + if isEditor then + if self.autoPlay then + self.debugTime = curTime % (self.compDurations[2] - self.compDurations[1]) + self.compDurations[1] + aeTime = self.debugTime + else + aeTime = self.debugTime + end + elseif self.effectType == EffectType.VideoAnimation or self.effectType == EffectType.Transition then + self.curTime = aeTime + end + + if self.lumi_obj then + self.lumi_obj:setEffectAttrRecursively("startTime", self.startTime) + self.lumi_obj:setEffectAttrRecursively("endTime", self.endTime) + self.lumi_obj:setEffectAttrRecursively("curTime", self.curTime) + self.lumi_obj:setEffectAttrRecursively("aeTime", aeTime) + self.lumi_obj:setEffectAttrRecursively("aeDuration", aeDuration) + end + + if self.lumi_params_setter and self.lumi_params_setter.initParams then + self.lumi_params_setter:initParams(self.lumi_obj) + end + if self.lumi_params_setter and self.lumi_params_setter.updateKeyFrameData then + self.lumi_params_setter:updateKeyFrameData(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateSlider then + self.lumi_params_setter:updateSlider(self.lumi_obj, aeTime) + end + if self.lumi_params_setter and self.lumi_params_setter.updateFade then + if self.effectType == EffectType.Effect then + self.lumi_params_setter:updateFade(self.lumi_obj, self.startTime, self.endTime, self.curTime, self.compDurations, aeTime) + end + end + + if self.lumi_obj and self.durations ~= nil then + aeTime = math.min(math.max(aeTime, self.compDurations[1]), self.compDurations[2]) + for entityName, durationMap in pairs(self.durations) do + local nodeDuration = durationMap['nodeDuration'] + local visible = false + for j = 1, #nodeDuration do + if nodeDuration[j][1] <= aeTime and aeTime < nodeDuration[j][2] then + visible = true + break + end + end + self.lumi_obj:setVisible(entityName, visible) + end + end + if self.lumi_obj and self.lumi_obj.updateMaterials then + self.lumi_obj:updateMaterials(deltaTime) + end +end + +-- function LumiManager:onLateUpdate(comp, deltaTime) +-- collectgarbage("collect") +-- end + +function LumiManager:onEvent(comp, event) + if self.lumiEffectRoot == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Lumi Effect Root is nil, please check') + return + end + + if self.lumi_obj == nil then + self:registerLumiObj(self.lumiEffectRoot, 1) + self:updateCameraLayerAndOrder() + end + + if self.lumi_obj == nil then + Amaz.LOGE(AE_EFFECT_TAG, 'Failed to find lumi_obj') + return + end + + if self.effectType == EffectType.Effect then + if event.args:get(0) == 'effects_adjust_speed' then + local value = event.args:get(1) + if self.animationInfos then + if value < 0 or value > 1 then + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid effects_adjust_speed value: ' .. value) + end + self.speed = remap(clamp(value, 0, 1), 0, 1, self.animationInfos.speedInfo[2], self.animationInfos.speedInfo[3]) + else + self.speed = value + end + end + elseif event.args:get(0) == 'start_time' and self.cameraMode then + self.cameraStartTime = event.args:get(2) + elseif event.args:get(0) == 'is_video' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.isVideo = event.args:get(2) + elseif event.args:get(0) == 'video_time' and (self.effectType == EffectType.EffectXT or self.effectType == EffectType.FilterXT) then -- deprecated after 1810 in XT + self.videoTime = event.args:get(2) + end + + if self.lumi_params_setter and self.lumi_params_setter.onEvent then + self.lumi_params_setter:onEvent(self.lumi_obj, event) + end +end + +exports.LumiManager = LumiManager +return exports diff --git a/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1e528b6007352c9831b71df7a92892be83703dc --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiObjectExtension.lua @@ -0,0 +1,436 @@ + +local LumiObjectExtension = {} +LumiObjectExtension.__index = LumiObjectExtension + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag-LumiObjectExtension' + +local function handleAllEntityBySingleParent(_trans, func, func2, ...) + if _trans.children:size() > 0 and func2(_trans, ...) then + for i = 1, _trans.children:size() do + local child = _trans.children:get(i-1) + handleAllEntityBySingleParent(child, func, func2, ...) + end + end + func(_trans, ...) +end + +local function CreateRenderTexture(width, height) + local rt = Amaz.RenderTexture() + rt.width = width + rt.height = height + rt.depth = 1 + rt.filterMag = Amaz.FilterMode.LINEAR + rt.filterMin = Amaz.FilterMode.LINEAR + rt.filterMipmap = Amaz.FilterMipmapMode.NONE + rt.attachment = Amaz.RenderTextureAttachment.NONE + return rt +end + +function LumiObjectExtension.register(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + + local self = setmetatable({}, LumiObjectExtension) + self.entity = _ent + self.scriptComp = scriptComp + self.trans = _ent:getComponent("Transform") + self.effect_lua = effect_lua + if effect_lua.__lumi_type~= nil then + self.__lumi_type = effect_lua.__lumi_type + else + self.__lumi_type = "lumi_obj" + end + if effect_lua.__lumi_rt_pingpong_type~= nil then + self.__lumi_rt_pingpong_type = effect_lua.__lumi_rt_pingpong_type + else + self.__lumi_rt_pingpong_type = "custom" + end + + if self.entity:getComponents("Camera"):size() > 0 then + Amaz.LOGE(AE_EFFECT_TAG, "Error: root entity has camera attached") + return nil + end + self.subLumiObjExt = {} + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local objExt = LumiObjectExtension.register(child.entity) + if objExt and child.entity.name ~= '' then + self.subLumiObjExt[child.entity.name] = objExt + end + end + end + effect_lua.__lumi_obj_ext = self + return self +end + +function LumiObjectExtension.deregister(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + local lumi_obj = effect_lua.__lumi_obj_ext + if lumi_obj == nil then return nil end + + if lumi_obj.__lumi_type == "lumi_effect" then + for i = 1, lumi_obj.trans.children:size() do + local child = lumi_obj.trans.children:get(i-1) + LumiObjectExtension.deregister(child.entity) + end + end + lumi_obj.entity = nil + lumi_obj.trans = nil + lumi_obj.effect_lua = nil + lumi_obj.scriptComp = nil + lumi_obj.subLumiObjExt = nil + lumi_obj.__lumi_type = nil + lumi_obj.__lumi_rt_pingpong_type = nil + effect_lua.__lumi_obj_ext = nil +end + +function LumiObjectExtension.getLumiObjExt(_ent) + if _ent == nil then return nil end + local scriptComp = _ent:getComponent("ScriptComponent") + if scriptComp == nil then return nil end + local effect_lua = Amaz.ScriptUtils.getLuaObj(scriptComp:getScript()) + if effect_lua == nil then return nil end + return effect_lua.__lumi_obj_ext +end + +function LumiObjectExtension:searchSubLumiObjExt(name) + if self.trans.entity.name == name then + return self + end + if name and self.subLumiObjExt[name] then + return self.subLumiObjExt[name] + end + for _, subObj in pairs(self.subLumiObjExt) do + local obj = subObj:searchSubLumiObjExt(name) + if obj then + return obj + end + end + return nil +end + +function LumiObjectExtension:setInputTex(_tex) + if self.effect_lua then + self.effect_lua.InputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('InputTex', _tex) + end + end +end + +function LumiObjectExtension:setOutputTex(_tex) + if self.effect_lua then + self.effect_lua.OutputTex = _tex + if self.scriptComp and self.scriptComp.properties then + self.scriptComp.properties:set('OutputTex', _tex) + end + end +end + +function LumiObjectExtension:getInputTex() + if self.effect_lua then + return self.effect_lua.InputTex + end + return nil +end + +function LumiObjectExtension:getOutputTex() + if self.effect_lua then + return self.effect_lua.OutputTex + end + return nil +end + +function LumiObjectExtension:setInputTexSizes(inputSize, originalSize) + assert(type(inputSize)=="table", "inputSize should be table") + if self.effect_lua and self.effect_lua.setInputTexSize then + self.effect_lua:setInputTexSize(inputSize) + end + if self.effect_lua and self.effect_lua.setInputOriginalTexSize then + self.effect_lua:setInputOriginalTexSize(originalSize) + end + self._inputTexSize, self._originalTexSize = inputSize, originalSize +end + +function LumiObjectExtension:getOutputTexSizes() + local inputSize = (self.effect_lua and self.effect_lua.getOutputTexSize) and self.effect_lua:getOutputTexSize() or self._inputTexSize + local originalSize = (self.effect_lua and self.effect_lua.getOutputOriginalTexSize) and self.effect_lua:getOutputOriginalTexSize() or self._originalTexSize + return inputSize, originalSize +end + +function LumiObjectExtension:needChangeOutputTexSize() + if self.effect_lua and self.effect_lua.__lumi_will_change_out_size then + return self.effect_lua.__lumi_will_change_out_size + end + if self._inputTexSize~=nil and self.effect_lua and self.effect_lua.getOutputTexSize then + local outSize = self.effect_lua:getOutputTexSize() + return (outSize[1] ~= self._inputTexSize[1] or outSize[2] ~= self._inputTexSize[2]) + end + return false +end + +function LumiObjectExtension:updateRt(_input_tex, _output_tex, _pingpong_tex) + self:setInputTex(_input_tex) + self:setOutputTex(_output_tex) + if self.effect_lua and self.effect_lua.updateRenderTexture ~= nil then + self.effect_lua:updateRenderTexture() + end + if self.__lumi_type == "lumi_effect" and self.__lumi_rt_pingpong_type == "auto" then + local lumi_obj_list = {} + local function collect_lumi_obj(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and (lumi_obj_ext.__lumi_type == "lumi_obj" or lumi_obj_ext.__lumi_rt_pingpong_type == "custom") then + table.insert(lumi_obj_list, lumi_obj_ext) + end + end + local function collect_lumi_obj_flag(_trans) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(_trans.entity) + if lumi_obj_ext and lumi_obj_ext.__lumi_type == "lumi_effect" and lumi_obj_ext.__lumi_rt_pingpong_type == "auto" then + return true + end + return false + end + handleAllEntityBySingleParent(self.trans, collect_lumi_obj, collect_lumi_obj_flag) + + if _pingpong_tex then + self._pingpong_tex = _pingpong_tex + elseif #lumi_obj_list > 1 then + self._pingpong_tex = CreateRenderTexture(_output_tex.width, _output_tex.height) + end + local pingpong = { _output_tex, self._pingpong_tex } + if #lumi_obj_list%2 == 0 then + pingpong = { self._pingpong_tex, _output_tex } + end + for i = 1, #lumi_obj_list do + local lumi_obj = lumi_obj_list[i] + if lumi_obj then + local idx1 = (i-1)%2+1 + local idx2 = (i)%2+1 + if i == 1 then + lumi_obj:setInputTex(_input_tex) + lumi_obj:setOutputTex(pingpong[idx1]) + else + lumi_obj:setInputTex(pingpong[idx2]) + lumi_obj:setOutputTex(pingpong[idx1]) + end + if lumi_obj.effect_lua and lumi_obj.effect_lua.updateRenderTexture ~= nil then + lumi_obj.effect_lua:updateRenderTexture() + end + end + end + end +end + +function LumiObjectExtension:updateOutputRtSize(width, height) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i - 1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateOutputRtSize(width, height) + end + end + end + local tex = self:getOutputTex() + if tex then + tex.width = width + tex.height = height + end +end + +function LumiObjectExtension:getCameraCount() + local cam_count = 0 + + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + cam_count = cam_count + lumi_obj_ext:getCameraCount() + else + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + elseif self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local cam = child.entity:getComponent("Camera") + if cam then + cam_count = cam_count + 1 + end + end + end + + return cam_count +end + +local function _setLayer(_cam, _layer) + local str = "1" + for i = 1, _layer do + str = str.."0" + end + local dynamic_bitset = Amaz.DynamicBitset.new(str) + + _cam.layerVisibleMask = dynamic_bitset +end + +function LumiObjectExtension:updateCameraLayerAndOrder(_start_layer, _start_order) + function updateRendererEntityLayer(trans, layer) + local renderers = trans.entity:getComponentsRecursive("Renderer") + for i = 0, renderers:size() - 1 do + local renderer = renderers:get(i) + if renderer then + renderer.entity.layer = layer + end + end + end + + local lastCamera = nil + + local cur_start_layer = _start_layer + local cur_start_order = _start_order + + if self.__lumi_type == "lumi_obj" then + for i = 1, self.trans.children:size() do + local curTrans = self.trans.children:get(i-1) + local cam = curTrans.entity:getComponent("Camera") + if cam then + if lastCamera then + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + lastCamera = cam + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, curTrans.children:size() do + local rendererTrans = curTrans.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + elseif lastCamera then + updateRendererEntityLayer(curTrans, cur_start_layer) + end + end + + elseif self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateCameraLayerAndOrder(cur_start_layer, cur_start_order) + local cam_count = lumi_obj_ext:getCameraCount() + cur_start_layer = cur_start_layer + cam_count + cur_start_order = cur_start_order + cam_count + else + local cam = child.entity:getComponent("Camera") + if cam then + cam.renderOrder = cur_start_order + _setLayer(cam, cur_start_layer) + for j = 1, child.children:size() do + local rendererTrans = child.children:get(j-1) + updateRendererEntityLayer(rendererTrans, cur_start_layer) + end + cur_start_order = cur_start_order + 1 + cur_start_layer = cur_start_layer + 1 + end + end + end + end + + return cur_start_layer, cur_start_order +end + +function LumiObjectExtension:setEffectAttr(key, value) + if self.effect_lua and self.effect_lua.setEffectAttr ~= nil then + self.effect_lua:setEffectAttr(key, value, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + self.effect_lua[key] = value + if self.scriptComp and self.scriptComp.properties ~= nil then + self.scriptComp.properties:set(key, value) + end + end + end +end + +function LumiObjectExtension:getEffectAttr(key) + if self.effect_lua and self.effect_lua.getEffectAttr ~= nil then + return self.effect_lua:getEffectAttr(key, self.scriptComp) + else + if self.effect_lua and self.effect_lua[key] ~= nil then + return self.effect_lua[key] + end + end + return nil +end + +function LumiObjectExtension:setSubEffectAttr(subName, key, value) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + subObj:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:getSubEffectAttr(subName, key) + local subObj = self:searchSubLumiObjExt(subName) + if subObj then + return subObj:getEffectAttr(key) + end + return nil +end + +function LumiObjectExtension:setEffectAttrRecursively(key, value) + if self.__lumi_type == "lumi_effect" then + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:setEffectAttrRecursively(key, value) + end + end + self:setEffectAttr(key, value) + elseif self.__lumi_type == "lumi_obj" then + self:setEffectAttr(key, value) + end +end + +function LumiObjectExtension:updateMaterials(time) + if self.effect_lua and self.scriptComp and self.entity and self.entity.visible then + if self.effect_lua.updateMaterial ~= nil then + self.effect_lua:updateMaterial(self.scriptComp, time) + elseif self.effect_lua.onUpdate ~= nil then + self.effect_lua:onUpdate(self.scriptComp, time) + end + + for i = 1, self.trans.children:size() do + local child = self.trans.children:get(i-1) + local lumi_obj_ext = LumiObjectExtension.getLumiObjExt(child.entity) + if lumi_obj_ext then + lumi_obj_ext:updateMaterials(time) + end + end + end +end + +function LumiObjectExtension:setVisible(subName, visible) + local subObj = self:searchSubLumiObjExt(subName) + if subObj and subObj.effect_lua then + if subObj.effect_lua.setVisible then + subObj.effect_lua:setVisible(visible) + else + subObj.entity.visible = visible + end + end +end + +return LumiObjectExtension diff --git a/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua new file mode 100644 index 0000000000000000000000000000000000000000..91587ae17803e82e95608198114893dfe226a5c9 --- /dev/null +++ b/scripts/7681256417281527061/AmazingFeature/lua/LumiFamily/LumiParamsSetter.lua @@ -0,0 +1,388 @@ +local LumiParamsSetter = {} +LumiParamsSetter.__index = LumiParamsSetter + +local AE_EFFECT_TAG = 'AE_EFFECT_TAG LumiTag' + +function LumiParamsSetter.new(lumiManager, params, keyframes, effectType, sliderInfos, fadeinInfos, fadeoutInfos) + local self = setmetatable({}, LumiParamsSetter) + self.lumiManager = lumiManager + self.params = params + self.keyframes = keyframes + self.sliderInfos = sliderInfos + self.sliderParams = {} + self.XTEvent = (effectType == 'xtFilter' or effectType == 'xtEffect') + self.fadeinInfos = fadeinInfos + self.fadeoutInfos = fadeoutInfos + self.afterSliderParams = {} + + return self +end + +local function clamp(val, min, max) + return math.max(math.min(val, max), min) +end + +local function mix(a, b, t) + return a * (1 - t) + b * t +end + +local function cvtTable2Amaz(attrType, v) + local value = nil + if attrType == "number" then + if #v == 1 then + value = v[1] + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "vector" then + if #v == 2 then + value = Amaz.Vector2f(v[1], v[2]) + elseif #v == 3 then + value = Amaz.Vector3f(v[1], v[2], v[3]) + elseif #v == 4 then + value = Amaz.Vector4f(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + elseif attrType == "color" then + if #v == 3 then + value = Amaz.Color(v[1], v[2], v[3], 1.0) + elseif #v == 4 then + value = Amaz.Color(v[1], v[2], v[3], v[4]) + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. " size: " .. #v) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key .. "unsupported type: " .. attrType) + end + return value +end + +local function getValueType(value) + local valueType = type(value) + if valueType == 'userdata' then + local str = tostring(value) + if string.sub(str, 1, 6) == 'Vector' then + valueType = 'vector' + elseif string.sub(str, 1, 5) == 'Color' then + valueType = 'color' + end + end + + return valueType +end + +local function add(value, number) + local type = getValueType(value) + if type == 'number' then + return value + number + elseif type == 'vector' then + local ret = value:copy() + ret.x = ret.x + number + ret.y = ret.y + number + if ret.z then ret.z = ret.z + number end + if ret.w then ret.w = ret.w + number end + return ret + elseif type == 'color' then + return Amaz.Color( + value.r + number, + value.g + number, + value.b + number, + value.a + number + ) + end + return nil +end + +local function mul(value, number) + local type = getValueType(value) + if type == 'color' then + return Amaz.Color( + value.r * number, + value.g * number, + value.b * number, + value.a * number + ) + end + return value * number +end + +function LumiParamsSetter:getCurrentDefaultParam(entityName, key, aeTime) + local keyframeName = nil + local keyframeType = 'number' + if self.keyframes ~= nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'number' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'vector' + keyframeType = 'vector' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = entityName .. '#' .. key .. '#' .. 'color' + keyframeType = 'color' + if self.keyframes.attrs[keyframeName] == nil then + keyframeName = nil + end + end + end + + if keyframeName == nil then + if entityName:sub(1, #'LumiLayer') == 'LumiLayer' and key:sub(-#'position') == 'position' then + local entity = self.params[entityName] + if entity ~= nil then + local position = entity[key] + if position ~= nil then + local hasSeparated = false + local newPosition = position:copy() + + local newKey = string.gsub(key, 'position', 'xPosition') + local newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.x = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'yPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.y = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + newKey = string.gsub(key, 'position', 'zPosition') + newKeyframeName = entityName .. '#' .. newKey .. '#' .. 'number' + if self.keyframes.attrs[newKeyframeName] ~= nil then + newPosition.z = cvtTable2Amaz('number', self.keyframes:GetVal(newKeyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + hasSeparated = true + end + + if hasSeparated then + return newPosition + end + end + end + end + end + end + + local value = nil + if keyframeName ~= nil then + value = cvtTable2Amaz(keyframeType, self.keyframes:GetVal(keyframeName, self.lumiManager:getKeyframeAeTime(aeTime))) + else + local entity = self.params[entityName] + if entity ~= nil then + value = entity[key] + end + end + return value +end + +function LumiParamsSetter:updateSlider(lumi_obj, aeTime) + -- local sliderIntensity = self.sliderParams['effects_adjust_blur'] + -- local gaussianIntensity = self:getCurrentDefaultParam("Gaussian_Blur_Root_353-effect2", 'intensity', aeTime) + -- if sliderIntensity and gaussianIntensity then + -- lumi_obj:setSubEffectAttr("Gaussian_Blur_Root_353-effect2", 'intensity', gaussianIntensity*sliderIntensity) + -- end + + local function fsub(value, slider, valueA, valueB) + -- (param - sliderValue) * valueA + valueB + return (value - slider) * valueA + valueB + end + + local function fmul(value, slider, valueA, valueB) + -- (param - valueA) * sliderValue + valueB + return (value - valueA) * slider + valueB + end + + local function fadd(value, slider, valueA, valueB) + -- (param - valueA) * valueB + sliderValue + return (value - valueA) * valueB + slider + end + + self.afterSliderParams = {} + for sliderKey, paramsInfos in pairs(self.sliderInfos) do + if self.sliderParams[sliderKey] ~= nil then + for index, value in ipairs(paramsInfos) do + local sliderIntensity = self.sliderParams[sliderKey] + local entityName = value[1] + local paramKey = value[2] + local paramType = value[3] + local paramDimensionFlag = value[4] + local calcType = value[5] + local maxValue = value[6] + local minValue = value[7] + local defaultValue = value[8] + local valueA = value[9] + local valueB = value[10] + sliderIntensity = sliderIntensity * (maxValue - minValue) + minValue + local oriValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + oriValue = self.afterSliderParams[entityName .. '#' .. paramKey] + end + local newValue = oriValue + local calcFunc = nil + if calcType == 0 then + calcFunc = fsub + elseif calcType == 1 then + calcFunc = fmul + elseif calcType == 2 then + calcFunc = fadd + else + Amaz.LOGE(AE_EFFECT_TAG, 'Unknown calcType: ' .. calcType) + return + end + if paramType == 'number' then + if paramDimensionFlag[1] then newValue = calcFunc(oriValue, sliderIntensity, valueA[1], valueB[1]) end + elseif paramType == 'color' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.r = calcFunc(oriValue.r, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.g = calcFunc(oriValue.g, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.b = calcFunc(oriValue.b, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.a = calcFunc(oriValue.a, sliderIntensity, valueA[4], valueB[4]) end + elseif paramType == 'vector' then + newValue = oriValue:copy() + if paramDimensionFlag[1] then newValue.x = calcFunc(oriValue.x, sliderIntensity, valueA[1], valueB[1]) end + if paramDimensionFlag[2] then newValue.y = calcFunc(oriValue.y, sliderIntensity, valueA[2], valueB[2]) end + if paramDimensionFlag[3] then newValue.z = calcFunc(oriValue.z, sliderIntensity, valueA[3], valueB[3]) end + if paramDimensionFlag[4] then newValue.w = calcFunc(oriValue.w, sliderIntensity, valueA[4], valueB[4]) end + end + lumi_obj:setSubEffectAttr(entityName, paramKey, newValue) + self.afterSliderParams[entityName .. '#' .. paramKey] = newValue + end + end + end +end + +function LumiParamsSetter:updateFadeParams(lumi_obj, fadeInfos, factor, aeTime) + for i = 1, #fadeInfos.infos do + local entityName = fadeInfos.infos[i][1] + local paramKey = fadeInfos.infos[i][2] + local valueType = fadeInfos.infos[i][3] + local value = fadeInfos.infos[i][4] + + local curValue = nil + if self.afterSliderParams[entityName .. '#' .. paramKey] ~= nil then + curValue = self.afterSliderParams[entityName .. '#' .. paramKey] + else + curValue = self:getCurrentDefaultParam(entityName, paramKey, aeTime) + end + + if curValue ~= nil then + local needRenew = true + if valueType == 'number' then + curValue = mix(value[1], curValue, factor) + elseif valueType == 'color' then + curValue.r = mix(value[1], curValue.r, factor) + curValue.g = mix(value[2], curValue.g, factor) + curValue.b = mix(value[3], curValue.b, factor) + curValue.a = mix(value[4], curValue.a, factor) + elseif valueType == 'vector' then + if #value <= 1 or #value >= 5 then + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid value size: ' .. #value) + else + if #value >= 2 then + curValue.x = mix(value[1], curValue.x, factor) + curValue.y = mix(value[2], curValue.y, factor) + end + if #value >= 3 then + curValue.z = mix(value[3], curValue.z, factor) + end + if #value >= 4 then + curValue.w = mix(value[4], curValue.w, factor) + end + end + else + needRenew = false + Amaz.LOGE(AE_EFFECT_TAG, 'Invalid valye type: ' .. valueType) + end + if needRenew then + lumi_obj:setSubEffectAttr(entityName, paramKey, curValue) + end + end + end +end + +function LumiParamsSetter:updateFade(lumi_obj, startTime, endTime, curTime, compDurations, aeTime) + local scale = (endTime - startTime) / (compDurations[2] - compDurations[1]) + scale = clamp(scale, 0, 1) + local runningTime = curTime - startTime + local remainingTime = endTime - curTime + + local isInFadein = false + if self.fadeinInfos + and self.fadeinInfos.time and self.fadeinInfos.time > 0 + and self.fadeinInfos.infos and #self.fadeinInfos.infos > 0 + then + local fadeinTime = self.fadeinInfos.time * scale + if runningTime <= fadeinTime then + isInFadein = true + local factor = runningTime / fadeinTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeinInfos, factor, aeTime) + end + end + + if self.fadeoutInfos + and self.fadeoutInfos.time and self.fadeoutInfos.time > 0 + and self.fadeoutInfos.infos and #self.fadeoutInfos.infos > 0 + then + local fadeoutTime = self.fadeoutInfos.time * scale + if remainingTime <= fadeoutTime or not isInFadein then + local factor = remainingTime / fadeoutTime + factor = clamp(factor, 0, 1) + self:updateFadeParams(lumi_obj, self.fadeoutInfos, factor, aeTime) + end + end +end + +function LumiParamsSetter:onEvent(lumi_obj, event) + if lumi_obj == nil or event == nil then return end + local key = event.args:get(0) + if self.sliderInfos[key] ~= nil then + if self.XTEvent then + self.sliderParams[key] = event.args:get(2); + else + self.sliderParams[key] = event.args:get(1); + end + end +end + +function LumiParamsSetter:initParams(lumi_obj) + if lumi_obj == nil then return end + if self.params == nil then return end + if self.init then return end + + for entityName, params in pairs(self.params) do + for key, value in pairs(params) do + lumi_obj:setSubEffectAttr(entityName, key, value) + end + end + + self.init = true +end + +function LumiParamsSetter:updateKeyFrameData(lumi_obj, aeTime) + if lumi_obj == nil then return end + if self.keyframes == nil then return end + + local p = aeTime + for key, _ in pairs(self.keyframes.attrs) do + local keys = {} + for substr in string.gmatch(key, "[^#]+") do + table.insert(keys, substr) + end + if #keys == 3 then + local entityName = keys[1] + local attrName = keys[2] + local attrType = keys[3] + local v = self.keyframes:GetVal(key, self.lumiManager:getKeyframeAeTime(p)) + local value = cvtTable2Amaz(attrType, v) + if value then + lumi_obj:setSubEffectAttr(entityName, attrName, value) + end + else + Amaz.LOGE(AE_EFFECT_TAG, "Invalid keyframe: " .. key) + end + end +end + +return LumiParamsSetter diff --git a/scripts/7681256417281527061/config.json b/scripts/7681256417281527061/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7d06e9a7026c97a152e179137c43310c765e3d16 --- /dev/null +++ b/scripts/7681256417281527061/config.json @@ -0,0 +1,15 @@ +{ + "ae_tool": "AEExporter:1.5.3", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8029 + } + ] + }, + "name": "AE2Effect_20260903183034313", + "version": "14.8.0" +} \ No newline at end of file diff --git a/scripts/7681256417281527061/extra.json b/scripts/7681256417281527061/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e6b748e1b7b1b6f1c714fedd8c7b87ebaef725 --- /dev/null +++ b/scripts/7681256417281527061/extra.json @@ -0,0 +1,6 @@ +{ + "transition": { + "defaultDura": 2.000001, + "isOverlap": true + } +} \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/content.json b/scripts/7681274733958122770/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/JSSys.js b/scripts/7681274733958122770/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +1 @@ +const{ShaderPass}=require("./ShaderPass.js");const getCurrentScene=require("./three-amg-wrapper.js").getCurrentScene;const RenderPass=require("./RenderPass.js").RenderPass;const Texture=require("./wrapper/Texture").Texture;const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class EffectComposer{constructor(renderer){this.renderer=renderer;this.passes=[];this.scene=getCurrentScene();this.rt_0=this.scene._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this.rt_prev_Texture=null;this.rt_next_Texture=null;this.sourceEntity=this.scene._amgScene.findEntityBy("PerspectiveCamera_w");this.sourceCamera=this.sourceEntity?this.sourceEntity.getComponent("Camera"):null;this.outputEntity=this.scene._amgScene.findEntityBy("Camera")||this.sourceEntity;this.outputCamera=this.outputEntity?this.outputEntity.getComponent("Camera"):null;this._outputIsPerspective=!!(this.outputEntity&&this.outputEntity.name==="PerspectiveCamera_w");this._initialInputTexture=this.rt_0;this._currentInputTexture=this._initialInputTexture;this._ppPassCount=0;this.finalPlaceHolder=this.scene._amgScene.findEntityBy("PlaceHolder");this.outputRT=this.scene._amgScene.assetMgr.SyncLoad("rt/outputTex.rt");if(this.sourceEntity){this.sourceEntity.layer=0;if(this.sourceCamera){this.sourceCamera.renderOrder=0;this.sourceCamera.renderTexture=this.rt_0}}}_getStartOrder(){let startOrder=0;for(let i=0;i { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-6 * k) * Math.cos(12 * k); +}; + +// 欠阻尼弹簧(硬):更高频振荡、更慢收敛 +const springStiff = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(18 * k); +}; + +// 阻尼振荡:sin 基波收尾抖动 +const dampedOscillation = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.exp(-5 * k) * Math.cos(10 * k); +}; + +const Physics = Object.freeze({ + SpringSoft: springSoft, + SpringStiff: springStiff, + DampedOscillation: dampedOscillation, +}); + +// ─── §4 Motion 动作设计系 ────────────────────────────────────────────────── + +// 先回拉 10% 再冲向终点:蓄力动作 +const anticipate = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const pullback = 0.1; + if (k < 0.3) { + const p = k / 0.3; + return -pullback * p * (2 - p); // easeOutQuad 到 -pullback + } + const p = (k - 0.3) / 0.7; + return -pullback + (1 + pullback) * p * p * (3 - 2 * p); // smoothstep 到 1 +}; + +// 冲到 peak 再回到 1 的工厂 +const overshootFactory = (peak) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return peak * p * (2 - p); // easeOutQuad 到 peak + } + const p = (k - 0.6) / 0.4; + return peak + (1 - peak) * (1 - Math.pow(1 - p, 3)); // easeOutCubic 到 1 +}; + +const overshoot110 = overshootFactory(1.10); +const overshoot125 = overshootFactory(1.25); + +// 快速到位(前 60% 冲到 1.05),后 40% 回到 1:磁吸、卡扣 +const snapBack = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.6) { + const p = k / 0.6; + return 1.05 * (1 - Math.pow(1 - p, 3)); + } + const p = (k - 0.6) / 0.4; + return 1.05 - 0.05 * p * p * (3 - 2 * p); +}; + +// 摆锤式:一次轻微过冲后收敛 +const swing = (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return 1 - Math.cos(1.5 * Math.PI * k) * Math.exp(-2.5 * k); +}; + +const Motion = Object.freeze({ + Anticipate: anticipate, + Overshoot110: overshoot110, + Overshoot125: overshoot125, + SnapBack: snapBack, + Swing: swing, +}); + +// ─── §5 Step 步进系 ──────────────────────────────────────────────────────── + +/** + * CSS steps() 等价工厂。 + * @param {number} n 段数 + * @param {'start' | 'end'} jumpTerm 跳变在每段的起始还是结束(默认 'end') + */ +const makeStep = (n, jumpTerm = 'end') => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (jumpTerm === 'start') return Math.ceil(k * n) / n; + return Math.floor(k * n) / n; +}; + +const Step = Object.freeze({ + Steps4End: makeStep(4, 'end'), + Steps8End: makeStep(8, 'end'), + Steps12End: makeStep(12, 'end'), +}); + +// ─── §6 Bezier 规范贝塞尔 ────────────────────────────────────────────────── + +/** + * 给定两个控制点 (x1,y1) 与 (x2,y2),P0=(0,0) P3=(1,1)。 + * 返回函数 f(t) -> y,其中 t 是输入时间(需先用牛顿法从 x 反解 s)。 + */ +function buildCubicBezier(x1, y1, x2, y2) { + const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx; + const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by; + const sampleX = (s) => ((ax * s + bx) * s + cx) * s; + const sampleY = (s) => ((ay * s + by) * s + cy) * s; + const sampleDX = (s) => (3 * ax * s + 2 * bx) * s + cx; + + const solveS = (x) => { + let s = x; + for (let i = 0; i < 8; i++) { + const cur = sampleX(s) - x; + if (Math.abs(cur) < 1e-6) return s; + const d = sampleDX(s); + if (Math.abs(d) < 1e-6) break; + s -= cur / d; + if (s < 0) s = 0; + if (s > 1) s = 1; + } + // 兜底二分 + let lo = 0, hi = 1; + for (let i = 0; i < 32 && hi - lo > 1e-6; i++) { + const mid = (lo + hi) / 2; + if (sampleX(mid) < x) lo = mid; else hi = mid; + } + return (lo + hi) / 2; + }; + + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return sampleY(solveS(k)); + }; +} + +// 贝塞尔白名单:(x1, y1, x2, y2) +const BEZIER_PRESETS = Object.freeze({ + 'Material.Standard': [0.4, 0, 0.2, 1], + 'Material.Accelerate': [0.4, 0, 1, 1], + 'Material.Decelerate': [0, 0, 0.2, 1], + 'CSS.Ease': [0.25, 0.1, 0.25, 1], +}); + +// 工厂 memoization(避免同参数重复构造) +const _bezierCache = new Map(); +function _cachedBezier(x1, y1, x2, y2) { + const key = x1 + ',' + y1 + ',' + x2 + ',' + y2; + let fn = _bezierCache.get(key); + if (!fn) { + fn = buildCubicBezier(x1, y1, x2, y2); + _bezierCache.set(key, fn); + } + return fn; +} + +/** + * cubicBezier('Material.Standard') | cubicBezier(x1, y1, x2, y2) + * 直写参数受控域:x1/x2 ∈ [0,1],y1/y2 ∈ [-0.5, 1.5] + */ +function cubicBezier(a, b, c, d) { + if (typeof a === 'string') { + let preset = BEZIER_PRESETS[a]; + if (!preset) { + console.warn('[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:', a); + preset = BEZIER_PRESETS['Material.Standard']; + } + return _cachedBezier(preset[0], preset[1], preset[2], preset[3]); + } + // 数值入口:裁剪到允许域 + const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v)); + const x1 = clamp(a, 0, 1); + const y1 = clamp(b, -0.5, 1.5); + const x2 = clamp(c, 0, 1); + const y2 = clamp(d, -0.5, 1.5); + return _cachedBezier(x1, y1, x2, y2); +} + +// 命名贝塞尔实例已整组移除:Material/CSS 预设与原生 Sinusoidal/Quadratic/Cubic +// 数值上几乎等价,特殊场景请直接调用 cubicBezier('Material.Standard') 等工厂。 + +// ═══════════════════════════════════════════════════════════════════════════ +// 扩展分组(与已有 6 组并列,不污染既有命名空间) +// ═══════════════════════════════════════════════════════════════════════════ + +// ─── §7 业界库扩展(已并入 Physics / Step / Heart) ───────────────────────── +// 以下工厂原本聚合在 Lib.* 命名空间下,现已按语义归入相应主题: +// Spring (Framer Motion) → Progress.Physics.Spring +// Steps (GSAP) → Progress.Step.Steps6 +// HeartBeat → Wave.Heart.Beat +// 退役:Framer Motion 的 Anticipate / GSAP 的 Overshoot factory(由 Motion.* +// 覆盖);GSAP ExpoScale / Unity SmoothDamp(数值上与原生 Sinusoidal/Quadratic +// 等价,已整组移除)。 + +// Spring(Framer Motion 风格):参数化弹簧,离散积分 +const libSpring = ({ stiffness = 180, damping = 12, mass = 1 } = {}) => { + const DT = 1 / 240; + const T = 1.5; + let x = 0, v = 0; + const samples = []; + for (let t = 0; t <= T; t += DT) { + const force = -stiffness * (x - 1) - damping * v; + v += (force / mass) * DT; + x += v * DT; + samples.push({ t, x }); + } + let T_end = T; + for (let i = samples.length - 1; i >= 0; i--) { + if (Math.abs(samples[i].x - 1) > 0.01) { T_end = samples[i].t; break; } + } + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const t = k * T_end; + const idx = Math.min(samples.length - 1, Math.floor(t / DT)); + return samples[idx].x; + }; +}; + +// HeartBeat(简易版):两高斯峰的绝对值轨迹 +const libHeartBeat = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c) => Math.exp(-((t - c) ** 2) / (2 * 0.07 * 0.07)); + return peak * (bell(k, 0.2) + bell(k, 0.5)); +}; + +// Steps(GSAP SteppedEase 风格 factory):离散 N 段阶梯(默认 n=6) +const libSteps = (n = 6) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return Math.floor(k * n) / n; +}; + +// ─── §8 Attention 注意力 / 抖振 ──────────────────────────────────────────── + +// Ping:单次衰减脉冲(雷达 ping),sin(π·k) × exp(-decay·k) +const attentionPing = (peak = 0.35, decay = 2) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(Math.PI * k) * Math.exp(-decay * k); +}; + +// Wiggle:衰减正弦振荡(easing 值本身,非位置增量) +const attentionWiggle = (count = 4, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + return amplitude * env * Math.sin(k * Math.PI * 2 * count); +}; + +// Strum:多峰衰减(吉他拨弦) +const attentionStrum = (notes = 4, peak = 0.4) => { + const centers = []; + for (let i = 0; i < notes; i++) { + centers.push({ c: 0.15 + i * (0.7 / Math.max(1, notes - 1)), a: Math.pow(0.72, i) }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * 0.05 * 0.05)); + } + return peak * sum; + }; +}; + +const Attention = Object.freeze({ + Ping: attentionPing(), + Wiggle: attentionWiggle(), + Strum: attentionStrum(), +}); + +// ─── §9 Breath 呼吸 ──────────────────────────────────────────────────────── + +// Normal:慢节奏正弦呼吸 +const breathNormal = (cycles = 2, peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.sin(k * Math.PI * 2 * cycles) * Math.sin(k * Math.PI); +}; + +// Deep:深呼吸——慢吸气 → hold → 慢呼气 +const breathDeep = (peak = 0.3, riseRatio = 0.35, holdRatio = 0.15) => { + const holdEnd = riseRatio + holdRatio; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + if (k < holdEnd) { + return peak; + } + const t = (k - holdEnd) / (1 - holdEnd); + return peak * Math.cos(t * Math.PI / 2); + }; +}; + +// Panting:急促浅呼吸——多次小幅起伏 + 正弦包络 +const breathPanting = (cycles = 6, peak = 0.08) => (k) => { + if (k <= 0 || k >= 1) return 0; + const envelope = Math.sin(k * Math.PI); + const wave = 0.5 + 0.5 * Math.sin(k * Math.PI * 2 * cycles - Math.PI / 2); + return peak * envelope * wave; +}; + +// Sigh:叹息——快速吸气后慢速释放 +const breathSigh = (peak = 0.25, riseRatio = 0.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return peak * Math.sin(t * Math.PI / 2); + } + const t = (k - riseRatio) / (1 - riseRatio); + return peak * (1 - t) * (1 - t); +}; + +const Breath = Object.freeze({ + Normal: breathNormal(), + Deep: breathDeep(), + Panting: breathPanting(), + Sigh: breathSigh(), +}); + +// ─── §10 Heart 心跳 ──────────────────────────────────────────────────────── + +// Calm:单次舒缓心跳——单高斯峰 +const heartCalm = (peak = 0.25, center = 0.35, width = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + return peak * Math.exp(-((k - center) ** 2) / (2 * width * width)); +}; + +// Excited:兴奋/紧张——密集快速心跳(N 连击) +const heartExcited = (beats = 4, peak = 0.3, width = 0.04) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < beats; i++) { + centers.push(0.15 + i * (span / Math.max(1, beats - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * width * width)); + } + return peak * sum; + }; +}; + +// LubDub:标准心跳「lub-dub」双音节 +const heartLubDub = (peak = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + // lub(S1):中心 0.25、宽 0.045、幅 1.0 + // dub(S2):中心 0.42、宽 0.03、幅 0.6 + return peak * (bell(k, 0.25, 0.045) + 0.6 * bell(k, 0.42, 0.03)); +}; + +const Heart = Object.freeze({ + Calm: heartCalm(), + Excited: heartExcited(), + LubDub: heartLubDub(), +}); + +// ─── §11 Math 物理 / 数学 ───────────────────────────────────────────────── + +// JumpArc:抛物线轨迹 4k(1-k) +const mathJumpArc = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 4 * k * (1 - k); +}; + +// Pendulum:物理摆——sin(πk) 包络的衰减余弦,端点归零(满足 Wave 契约 f(0)=f(1)=0) +const mathPendulum = (damping = 3, freq = 2.5) => (k) => { + if (k <= 0 || k >= 1) return 0; + return Math.sin(k * Math.PI) * Math.exp(-damping * k) * Math.cos(freq * Math.PI * k); +}; + +// Tremor:持续高频小幅抖动(不衰减),整体沿 Linear 进行 +const mathTremor = (amplitude = 0.04, freq = 22) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + return k + amplitude * Math.sin(k * Math.PI * 2 * freq); +}; + +// Boomerang 包装器:把任意 easing 包装成 0→1→0(先去再回)。 +// 仅作为内部辅助使用,不暴露为公共曲线——常用变体已预实例化为 +// Pulse.Math.BoomerangSharp / BoomerangSoft(见 Pulse 命名空间)。 +const mathBoomerang = (fn) => (k) => { + if (k <= 0 || k >= 1) return 0; + return k < 0.5 ? fn(k * 2) : fn(2 - k * 2); +}; + +const MathExt = Object.freeze({ + JumpArc: mathJumpArc(), + Pendulum: mathPendulum(), + Tremor: mathTremor(), +}); + +// ─── §12 Explosion 爆炸 ──────────────────────────────────────────────────── + +// Impulse:指数脉冲响应 k·e^(1-k·sharpness)(减线性尾项使 k=1 归 0) +const explosionImpulse = (sharpness = 6) => { + const tail = sharpness * Math.exp(1 - sharpness); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const h = sharpness * k; + return h * Math.exp(1 - h) - tail * k; + }; +}; + +// Flash:瞬间拉满 + 指数衰减到 0 +const explosionFlash = (rise = 0.05, decay = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < rise) return k / rise; + return Math.exp(-decay * (k - rise)); +}; + +// Recoil:爆炸反冲——负向冲击 -1 + 阻尼振荡 +const explosionRecoil = (decay = 4, freq = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + return -Math.exp(-decay * k) * Math.cos(freq * Math.PI * k); +}; + +// Implosion:三段式——负向吸能 → 正向爆发 → 衰减归 0 +const explosionImplosion = (charge = 0.3, depth = 0.4, burstPeak = 1.2) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < charge) { + const t = k / charge; + return -depth * Math.sin(t * Math.PI / 2); + } + const t = (k - charge) / (1 - charge); + const h = sharp * t; + const wave = h * Math.exp(1 - h) - tail * t; + const settle = -depth * Math.pow(1 - t, 3); + return settle + burstPeak * wave; + }; +}; + +const Explosion = Object.freeze({ + Impulse: explosionImpulse(), + Flash: explosionFlash(), + Recoil: explosionRecoil(), + Implosion: explosionImplosion(), +}); + +// ─── §13 Cinema(已整组移除:Creep=k^3.5 与 Cubic.In/Quartic.In 数值等价) ─ + +// ─── §14 Nature 自然现象 ─────────────────────────────────────────────────── + +// Wave:海浪律动——多谐波叠加 + 整体正弦包络 +const natureWave = (cycles = 3, amplitude = 0.25) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const w = Math.sin(k * Math.PI * 2 * cycles) + + 0.5 * Math.sin(k * Math.PI * 2 * cycles * 1.5 + 1.2) + + 0.25 * Math.sin(k * Math.PI * 2 * cycles * 3 + 2.4); + return amplitude * env * w * 0.6; +}; + +// Flicker:火焰闪烁——伪随机采样 + 线性插值 + 正弦包络 +const natureFlicker = (rate = 15, intensity = 0.2, seed = 7) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= rate + 1; i++) samples.push(rand()); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * rate; + const idx = Math.floor(pos); + const t = pos - idx; + const a = samples[idx]; + const b = samples[idx + 1]; + const interp = a + (b - a) * t; + return intensity * env * (interp - 0.5) * 2; + }; +}; + +// Gust:风——N 次高斯阵风叠加 +const natureGust = (gusts = 3, peak = 0.25) => { + const centers = []; + const span = 0.7; + for (let i = 0; i < gusts; i++) { + centers.push(0.15 + i * (span / Math.max(1, gusts - 1))); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const c of centers) { + sum += Math.exp(-((k - c) ** 2) / (2 * 0.08 * 0.08)); + } + return peak * sum / gusts * 1.8; + }; +}; + +const Nature = Object.freeze({ + Wave: natureWave(), + Flicker: natureFlicker(), + Gust: natureGust(), +}); + +// ─── §15 Impact 撞击 / 落地 ──────────────────────────────────────────────── + +// Rain:雨滴下落——重力加速段 + 撞击 + 小幅余震 +const impactRain = (impactAt = 0.7, rippleAmp = 0.08) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + return 1 + rippleAmp * Math.exp(-4 * t) * Math.sin(t * Math.PI * 6); +}; + +// Hammer:锤击——抬起蓄力(负值)→ 快速下击 → 微反弹 +const impactHammer = (liftDepth = 0.25) => { + const liftEnd = 0.35, strikeEnd = 0.6; + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < liftEnd) { + const t = k / liftEnd; + return -liftDepth * Math.sin(t * Math.PI); + } + if (k < strikeEnd) { + const t = (k - liftEnd) / (strikeEnd - liftEnd); + return t * t; + } + const t = (k - strikeEnd) / (1 - strikeEnd); + return 1 - 0.06 * Math.exp(-5 * t) * Math.sin(t * Math.PI * 4); + }; +}; + +// BounceDrop:下落 + 多次衰减反弹 +const impactBounceDrop = (bounces = 3, rebound = 0.25) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return t * t; + } + const t = (k - 0.4) / 0.6; + const env = Math.exp(-2.5 * t); + const wave = Math.abs(Math.sin(t * Math.PI * bounces)); + return 1 - env * wave * rebound; +}; + +// Slap:拍击——快速接触 + 短暂保持 + 快速撤回 +const impactSlap = (contactAt = 0.3, holdRatio = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < contactAt) { + const t = k / contactAt; + return t * t; + } + if (k < contactAt + holdRatio) return 1; + const t = (k - contactAt - holdRatio) / (1 - contactAt - holdRatio); + return (1 - t) * (1 - t); +}; + +// ArrowHit:箭中靶——匀速飞行 + 命中 + 插入后高频振颤衰减 +const impactArrowHit = (impactAt = 0.5) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * (0.7 + 0.3 * t); + } + const t = (k - impactAt) / (1 - impactAt); + const env = Math.exp(-5 * t); + const wave = Math.sin(t * Math.PI * 10); + return 1 + 0.1 * env * wave; +}; + +// Shatter:撞碎——下落 + 撞击 + 能量 impulse 爆发 + 回到 1 +const impactShatter = (impactAt = 0.55, burstAmp = 0.35) => { + const sharp = 5; + const tail = sharp * Math.exp(1 - sharp); + return (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < impactAt) { + const t = k / impactAt; + return t * t; + } + const t = (k - impactAt) / (1 - impactAt); + const h = sharp * t; + const impulseVal = h * Math.exp(1 - h) - tail * t; + return 1 + burstAmp * impulseVal; + }; +}; + +const Impact = Object.freeze({ + Rain: impactRain(), + Hammer: impactHammer(), + BounceDrop: impactBounceDrop(), + Slap: impactSlap(), + ArrowHit: impactArrowHit(), + Shatter: impactShatter(), +}); + +// ─── §16 Rhythm 节奏 / 冲击 ──────────────────────────────────────────────── + +// BassDrop:EDM 重拍——缓慢蓄力 → pause pre-drop → 瞬间掉到 1 → 持续并有微脉动 +const rhythmBassDrop = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return 0.4 * Math.pow(t, 2.5); + } + if (k < 0.48) { + const t = (k - 0.4) / 0.08; + return 0.4 - 0.2 * t; + } + if (k < 0.52) { + const t = (k - 0.48) / 0.04; + return 0.2 + 0.8 * t; + } + const t = (k - 0.52) / 0.48; + return 1 - 0.04 * Math.sin(t * Math.PI * 8) * (1 - t); +}; + +// PunchCombo:拳击三连击——jab-jab-cross,第三拳最重最宽 +const rhythmPunchCombo = (peak = 0.4) => { + const pattern = [ + { c: 0.15, w: 0.04, a: 0.75 }, + { c: 0.35, w: 0.04, a: 0.75 }, + { c: 0.7, w: 0.055, a: 1.0 }, + ]; + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of pattern) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return peak * sum; + }; +}; + +// Staccato:断奏——均匀节拍内 duty 占空比 sin 脉冲 +const rhythmStaccato = (beats = 4, duty = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const beatLen = 1 / beats; + const phase = (k / beatLen) - Math.floor(k / beatLen); + if (phase > duty) return 0; + const t = phase / duty; + return Math.sin(t * Math.PI); +}; + +// Kick:极限单击——瞬速冲到 peak,之后强指数衰减 +const rhythmKick = (peak = 1.2) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.05) return peak * k / 0.05; + const t = (k - 0.05) / 0.95; + return peak * Math.exp(-4 * t); +}; + +// Crescendo:渐强——N 次高斯峰,间距递减、幅度递增 +const rhythmCrescendo = (beats = 4) => { + const centers = []; + for (let i = 0; i < beats; i++) { + const t = Math.pow((i + 1) / beats, 1.4); + centers.push({ c: Math.max(0.05, t - 0.08), w: 0.03, a: (i + 1) / beats }); + } + return (k) => { + if (k <= 0 || k >= 1) return 0; + let sum = 0; + for (const { c, w, a } of centers) { + sum += a * Math.exp(-((k - c) ** 2) / (2 * w * w)); + } + return sum; + }; +}; + +// DunDunDun:悬疑递进——3 击幅度递增,末击更宽形成持续感 +const rhythmDunDunDun = () => { + const bell = (t, c, w) => Math.exp(-((t - c) ** 2) / (2 * w * w)); + return (k) => { + if (k <= 0 || k >= 1) return 0; + return 0.3 * bell(k, 0.15, 0.025) + + 0.6 * bell(k, 0.35, 0.03) + + 1.0 * bell(k, 0.68, 0.09); + }; +}; + +// BellToll:钟声——瞬间起振 + 指数衰减调幅的余弦振荡 +const rhythmBellToll = (decay = 3, freq = 8) => { + const strike = 0.05; + return (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < strike) return k / strike; + const t = k - strike; + return Math.exp(-decay * t) * Math.cos(freq * Math.PI * t); + }; +}; + +const Rhythm = Object.freeze({ + BassDrop: rhythmBassDrop(), + PunchCombo: rhythmPunchCombo(), + Staccato: rhythmStaccato(), + Kick: rhythmKick(), + Crescendo: rhythmCrescendo(), + DunDunDun: rhythmDunDunDun(), + BellToll: rhythmBellToll(), +}); + +// ─── §17 UI 反馈 ─────────────────────────────────────────────────────────── + +// ClickSnap:按钮点击——压下(负偏移)→ 回弹微过冲 → 归零 +const uiClickSnap = (pressDepth = 0.3, reboundPeak = 0.1) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.2) { + const t = k / 0.2; + return -pressDepth * Math.sin(t * Math.PI / 2); + } + if (k < 0.5) { + const t = (k - 0.2) / 0.3; + return -pressDepth + (pressDepth + reboundPeak) * (1 - Math.pow(1 - t, 3)); + } + const t = (k - 0.5) / 0.5; + return reboundPeak * Math.exp(-4 * t) * Math.cos(t * Math.PI * 3); +}; + +// HoverBloom:悬停高亮——梯形包络(快升 → plateau → 快降) +const uiHoverBloom = (riseRatio = 0.2, fallRatio = 0.3) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < riseRatio) { + const t = k / riseRatio; + return 1 - Math.pow(1 - t, 3); + } + if (k < 1 - fallRatio) return 1; + const t = (k - (1 - fallRatio)) / fallRatio; + return Math.pow(1 - t, 3); +}; + +// ErrorShake:错误反馈——方波化高频 shake +const uiErrorShake = (amplitude = 0.15, count = 5) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = 1 - k; + const raw = Math.sin(k * Math.PI * 2 * count); + const clipped = Math.sign(raw) * Math.min(1, Math.abs(raw) * 1.8); + return amplitude * env * clipped; +}; + +// SuccessPop:成功庆祝——瞬速 scale 到 1.2 → 阻尼余弦回到 1 +const uiSuccessPop = (overshoot = 0.2) => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.4) { + const t = k / 0.4; + return (1 + overshoot) * (1 - Math.pow(1 - t, 2)); + } + const t = (k - 0.4) / 0.6; + return 1 + overshoot * Math.exp(-5 * t) * Math.cos(t * Math.PI * 3); +}; + +// RippleOut:Material 点击涟漪——早峰后淡出 +const uiRippleOut = () => (k) => { + if (k <= 0 || k >= 1) return 0; + return 6.75 * k * Math.pow(1 - k, 2); +}; + +const UI = Object.freeze({ + ClickSnap: uiClickSnap(), + HoverBloom: uiHoverBloom(), + ErrorShake: uiErrorShake(), + SuccessPop: uiSuccessPop(), + RippleOut: uiRippleOut(), +}); + +// ─── §18 Magic 能量 / 魔法 ───────────────────────────────────────────────── + +// ManaCharge:魔法蓄能——指数积蓄 + 高频 pulses +const magicManaCharge = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + const base = (Math.exp(3 * k) - 1) / (Math.exp(3) - 1); + const pulse = 0.04 * Math.sin(k * Math.PI * 8) * k; + return base + pulse; +}; + +// SpellCast:施法——蓄能 + 瞬冲 1 + 拖尾衰减 +const magicSpellCast = (chargeEnd = 0.4) => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < chargeEnd) { + const t = k / chargeEnd; + return 0.3 * Math.pow(t, 2) * (1 + 0.2 * Math.sin(t * Math.PI * 6)); + } + if (k < chargeEnd + 0.1) { + const t = (k - chargeEnd) / 0.1; + return 0.3 + 0.7 * t; + } + const t = (k - chargeEnd - 0.1) / (1 - chargeEnd - 0.1); + return Math.exp(-2 * t) * (1 + 0.1 * Math.cos(t * Math.PI * 4)); +}; + +// Teleport:瞬移——加速压缩 → 完全消失(平顶 1)→ 加速重现 +const magicTeleport = () => (k) => { + if (k <= 0 || k >= 1) return 0; + if (k < 0.45) { + const t = k / 0.45; + return t * t * t; + } + if (k < 0.55) return 1; + const t = (k - 0.55) / 0.45; + return Math.pow(1 - t, 3); +}; + +// Shield:护盾——波纹扩散过冲到 1.2 → 稳定到 1 → 微脉动 +const magicShield = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.3) { + const t = k / 0.3; + return 1.2 * (1 - Math.pow(1 - t, 2)); + } + if (k < 0.6) { + const t = (k - 0.3) / 0.3; + return 1.2 - 0.2 * t; + } + const t = (k - 0.6) / 0.4; + return 1 + 0.03 * Math.sin(t * Math.PI * 3); +}; + +// MagicAura:魔法光环——基频 + 2 次谐波 + 3 次泛音的正弦叠加 +const magicAura = (peak = 0.15) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const fundamental = 0.6 * Math.sin(k * Math.PI * 2); + const harmonic = 0.3 * Math.sin(k * Math.PI * 4 + 1); + const overtone = 0.1 * Math.sin(k * Math.PI * 6 + 2); + return peak * env * (fundamental + harmonic + overtone); +}; + +const Magic = Object.freeze({ + ManaCharge: magicManaCharge(), + SpellCast: magicSpellCast(), + Teleport: magicTeleport(), + Shield: magicShield(), + MagicAura: magicAura(), +}); + +// ─── §19 Animal 动物动作 ─────────────────────────────────────────────────── + +// CatPounce:猫扑击——蹲伏蓄力 + 起跳 + 空中抛物线 + 落地微压 +const animalCatPounce = () => (k) => { + if (k <= 0) return 0; + if (k >= 1) return 1; + if (k < 0.2) { + const t = k / 0.2; + return -0.2 * Math.sin(t * Math.PI); + } + if (k < 0.3) { + const t = (k - 0.2) / 0.1; + return 0.5 * t * t; + } + if (k < 0.8) { + const t = (k - 0.3) / 0.5; + return 0.5 + 0.5 * t + 0.2 * Math.sin(t * Math.PI); + } + const t = (k - 0.8) / 0.2; + return 1 + 0.05 * Math.sin(t * Math.PI); +}; + +// BirdFlap:翅膀拍打——不对称基波(下扑快、上挥慢)+ sin 包络 +const animalBirdFlap = (flaps = 4) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const phase = k * Math.PI * 2 * flaps; + const wave = Math.sin(phase) - 0.3 * Math.sin(phase * 2); + return 0.2 * env * wave; +}; + +// SnakeSlither:蛇蜿蜒——连续 S 波 +const animalSnakeSlither = (waves = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const wave = Math.sin(k * Math.PI * 2 * waves); + return 0.2 * env * wave; +}; + +// ButterflyFlit:蝴蝶乱飞——seed 可复现的随机采样 + cubic 平滑插值 +const animalButterflyFlit = (seed = 13) => { + let s = seed; + const rand = () => { s = (s * 9301 + 49297) % 233280; return s / 233280; }; + const samples = []; + for (let i = 0; i <= 26; i++) samples.push(rand() - 0.5); + return (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const pos = k * 25; + const idx = Math.floor(pos); + const t = pos - idx; + const smooth = t * t * (3 - 2 * t); + const interp = samples[idx] + (samples[idx + 1] - samples[idx]) * smooth; + return 0.3 * env * interp; + }; +}; + +// HorseGallop:马奔驰——每周期 4 蹄击地 + 空中相位间隙 +const animalHorseGallop = (cycles = 3) => (k) => { + if (k <= 0 || k >= 1) return 0; + const env = Math.sin(k * Math.PI); + const cyclePos = (k * cycles) - Math.floor(k * cycles); + const bell = (c, w = 0.04) => Math.exp(-((cyclePos - c) ** 2) / (2 * w * w)); + return 0.25 * env * (bell(0.0) + bell(0.18) + bell(0.36) + bell(0.54)); +}; + +const Animal = Object.freeze({ + CatPounce: animalCatPounce(), + BirdFlap: animalBirdFlap(), + SnakeSlither: animalSnakeSlither(), + ButterflyFlit: animalButterflyFlit(), + HorseGallop: animalHorseGallop(), +}); + +// ─── 导出(形态分类:Progress / Pulse / Wave) ───────────────────────────── +// +// 上方各主题常量(Physics / Motion / Step / Attention / Breath / Heart / +// MathExt / Explosion / Nature / Impact / Rhythm / UI / Magic / Animal) +// 及业界库 factory(libSpring / libSteps / libHeartBeat)仅作为 +// "源池"使用,不再作为顶层导出;由下列 Progress / Pulse / Wave 三个按形态 +// 分类的命名空间统一暴露。 +// +// 通用 UI 柔化(Smooth / Bezier 两组共 6 条命名曲线)已整组移除——数值上 +// 与原生 Sinusoidal/Quadratic/Cubic 等价;需定制贝塞尔请直接调用顶层 +// cubicBezier('Material.Standard' | x1,y1,x2,y2) 工厂。 + +// Progress —— 单调或衰减至 1 的曲线(A→B 过渡) +const Progress = Object.freeze({ + // Physics:原生 + Spring(Framer Motion 参数化弹簧) + Physics: Object.freeze({ + ...Physics, // SpringSoft / SpringStiff / DampedOscillation + Spring: libSpring(), // Framer Motion 风格默认弹簧 + }), + Motion, // Anticipate / Overshoot110 / Overshoot125 / SnapBack / Swing + // Step:固定段数实例 —— Steps4/6/8/12End 覆盖实用区间,无任意段数工厂 + Step: Object.freeze({ + ...Step, // Steps4End / Steps8End / Steps12End + Steps6: libSteps(), + }), + Math: Object.freeze({ + Tremor: MathExt.Tremor, + }), + Impact: Object.freeze({ + Rain: Impact.Rain, + Hammer: Impact.Hammer, + BounceDrop: Impact.BounceDrop, + ArrowHit: Impact.ArrowHit, + Shatter: Impact.Shatter, + }), + Rhythm: Object.freeze({ + BassDrop: Rhythm.BassDrop, + }), + UI: Object.freeze({ + SuccessPop: UI.SuccessPop, + }), + Magic: Object.freeze({ + ManaCharge: Magic.ManaCharge, + Shield: Magic.Shield, + }), + Animal: Object.freeze({ + CatPounce: Animal.CatPounce, + }), +}); + +// Pulse —— 单次返零脉冲(f(0)=f(1)=0, 单主峰;reversals ≤ 2 为主) +const Pulse = Object.freeze({ + Attention: Object.freeze({ + Ping: Attention.Ping, + }), + Breath: Object.freeze({ + Deep: Breath.Deep, + Sigh: Breath.Sigh, + }), + Heart: Object.freeze({ + Calm: Heart.Calm, + }), + Math: Object.freeze({ + JumpArc: MathExt.JumpArc, // 对称抛物 4k(1-k) + BoomerangSharp: mathBoomerang(E.Cubic.In), // 尖峰回程:缓→冲到峰→缓回(峰值锐利) + BoomerangSoft: mathBoomerang(E.Cubic.Out), // 平顶回程:快→在峰上停留→快回(峰值平滑) + }), + Explosion: Object.freeze({ + Impulse: Explosion.Impulse, + Flash: Explosion.Flash, + Recoil: Explosion.Recoil, + Implosion: Explosion.Implosion, + }), + Impact: Object.freeze({ + Slap: Impact.Slap, + }), + Rhythm: Object.freeze({ + Kick: Rhythm.Kick, + }), + UI: Object.freeze({ + ClickSnap: UI.ClickSnap, + HoverBloom: UI.HoverBloom, + RippleOut: UI.RippleOut, + }), + Magic: Object.freeze({ + SpellCast: Magic.SpellCast, + Teleport: Magic.Teleport, + }), +}); + +// Wave —— 周期多峰振荡(f(0)=f(1)=0, 多次反转) +const Wave = Object.freeze({ + Attention: Object.freeze({ + Wiggle: Attention.Wiggle, + Strum: Attention.Strum, + }), + Breath: Object.freeze({ + Normal: Breath.Normal, + Panting: Breath.Panting, + }), + Heart: Object.freeze({ + Excited: Heart.Excited, + LubDub: Heart.LubDub, + Beat: libHeartBeat(), // 迁移自 Lib.HeartBeat + }), + Math: Object.freeze({ + Pendulum: MathExt.Pendulum, + }), + Nature, // Wave / Flicker / Gust + Rhythm: Object.freeze({ + PunchCombo: Rhythm.PunchCombo, + Staccato: Rhythm.Staccato, + Crescendo: Rhythm.Crescendo, + DunDunDun: Rhythm.DunDunDun, + BellToll: Rhythm.BellToll, + }), + UI: Object.freeze({ + ErrorShake: UI.ErrorShake, + }), + Magic: Object.freeze({ + MagicAura: Magic.MagicAura, + }), + Animal: Object.freeze({ + BirdFlap: Animal.BirdFlap, + SnakeSlither: Animal.SnakeSlither, + ButterflyFlit: Animal.ButterflyFlit, + HorseGallop: Animal.HorseGallop, + }), +}); + +const customEasings = Object.freeze({ + makeOutIn, + OutIn, + Progress, + Pulse, + Wave, + cubicBezier, +}); + +exports.customEasings = customEasings; +exports.default = customEasings; diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1 @@ +const TWEEN=require("./tween");const customEasings=require("./customEasings").customEasings;const THREE=require("./three-amg-wrapper").THREE;const{ShaderPass}=require("./ShaderPass.js");class ScriptScene{constructor(amgScene=null,container=null){if(amgScene){this.scene=new THREE.Scene;this.scene._amgScene=amgScene}else{this.scene=new THREE.Scene}this.effect_type="transition";this.camera=null;this.renderer=null;this.scene.background=new THREE.Color(3355443);this.isAnimating=false;this.animationFrameId=null;this.sceneObjects=null;this.texture1=null;this.texture2=null;this.composer=null;this.renderPass=null;this.usePostProcessing=true;this.initCoreObjects();if(container){this.init(container)}}destroy(){this.isAnimating=false;if(this.animationFrameId!==null&&typeof cancelAnimationFrame!=="undefined"){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}if(this.renderer){this.renderer.setAnimationLoop(null);this.renderer.dispose();if(this.renderer.domElement&&this.renderer.domElement.parentNode){this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}if(this.texture1){if(typeof this.texture1.dispose==="function")this.texture1.dispose();this.texture1=null}if(this.texture2){if(typeof this.texture2.dispose==="function")this.texture2.dispose();this.texture2=null}if(this.scene){this.scene.dispose()}if(typeof window!=="undefined"){window.removeEventListener("resize",this.handleResize)}if(this.sceneObjects&&this.sceneObjects.tweens){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.stop==="function"){tween.stop()}});this.sceneObjects.tweens=[]}if(this.shaderPasses&&this.shaderPasses.length){this.shaderPasses.forEach(pass=>{if(pass&&typeof pass.dispose==="function"){try{pass.dispose()}catch(e){}}});this.shaderPasses=[]}if(this.shaderPass&&typeof this.shaderPass.dispose==="function"){try{this.shaderPass.dispose()}catch(e){}}this.shaderPass=null;if(this.composer){this.composer.dispose();this.composer=null}this.renderPass=null;this.scene=null;this.camera=null;this.renderer=null;this.sceneObjects=null}initCoreObjects(){if(typeof window!=="undefined"){if(!window.innerWidth||!window.innerHeight){window.innerWidth=600;window.innerHeight=600}window.devicePixelRatio=window.devicePixelRatio||1;if(this.scene&&this.scene._amgScene&&this.scene._amgScene.assetMgr){const inputTexture=this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");if(inputTexture&&inputTexture.width>0&&inputTexture.height>0){window.innerWidth=inputTexture.width;window.innerHeight=inputTexture.height}}}this.camera=new THREE.PerspectiveCamera(53.1,window.innerWidth/window.innerHeight,.1,1e4);this.camera.position.z=10;this.scene.add(this.camera);if(this.scene._amgScene==null){this.renderer=new THREE.WebGLRenderer({antialias:true});this.renderer.outputColorSpace=THREE.LinearSRGBColorSpace}if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight);this.renderer.setPixelRatio(window.devicePixelRatio)}this.sliders={};this.TWEEN=TWEEN;this.customEasings=customEasings;this.Duration=2e3}addShaderPass(shaderPassConfigs){if(!Array.isArray(shaderPassConfigs)){shaderPassConfigs=[shaderPassConfigs]}shaderPassConfigs.forEach(config=>{const atomicName=config.name;const className=atomicName.startsWith("Lumi")?atomicName.substring(4):atomicName;const shaderPassModule=require("../pp/Lumi"+className+"/"+className+"ShaderPass.js");const ShaderPassClass=shaderPassModule[className+"ShaderPass"];const initConfig=config&&(config.initConfig||config.config||config.params)||{};const shaderPass=new ShaderPassClass(initConfig);this.composer.addPass(shaderPass);this.shaderPasses.push(shaderPass)})}setupPostProcessing(shaderPassConfigs){const{EffectComposer}=require("./EffectComposer.js");const{RenderPass}=require("./RenderPass.js");this.composer=new EffectComposer(this.renderer);this.renderPass=new RenderPass(this.scene,this.camera);this.composer.addPass(this.renderPass);this.shaderPasses=[];this.addShaderPass(shaderPassConfigs)}initPostProcessing(){}init(container){if(this.renderer){if(container){container.appendChild(this.renderer.domElement)}else if(typeof document!=="undefined"){document.body.appendChild(this.renderer.domElement)}}if(typeof window!=="undefined"){window.addEventListener("resize",()=>this.handleResize())}}start(updateCallback){if(this.isAnimating)return;this.isAnimating=true;if(updateCallback){const animateFrame=()=>{if(!this.isAnimating)return;updateCallback();this.animationFrameId=requestAnimationFrame(animateFrame)};animateFrame()}else{this.renderer.setAnimationLoop(()=>{this.update()})}}updateScene(timestamp){if(!this.isAnimating){this.isAnimating=true}this.defaultUpdate(timestamp)}update(){if(this.usePostProcessing&&this.composer){if(this.renderPass){this.renderPass.camera=this.camera}this.composer.render()}else if(this.renderer){this.renderer.render(this.scene,this.camera)}}handleResize(){this.camera.aspect=window.innerWidth/window.innerHeight;this.camera.updateProjectionMatrix();if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight)}if(!this.isAnimating){this.update()}}loadTextures(){const textureLoader=new THREE.TextureLoader;return Promise.all([new Promise(resolve=>{this.texture1=textureLoader.load("image/Sample1.jpg",resolve);this.texture1.colorSpace=THREE.LinearSRGBColorSpace;this.texture1.wrapS=THREE.RepeatWrapping;this.texture1.wrapT=THREE.RepeatWrapping}),new Promise(resolve=>{this.texture2=textureLoader.load("image/Sample2.jpg",resolve);this.texture2.colorSpace=THREE.LinearSRGBColorSpace;this.texture2.wrapS=THREE.RepeatWrapping;this.texture2.wrapT=THREE.RepeatWrapping})])}_applyTweenInitialState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,0);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,0)}}_applyTweenFinalState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,1);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,1)}}seekToTime(time){if(!this.isAnimating){this.isAnimating=true}const clampedTime=Math.max(0,Math.min(time,this.Duration));if(this._predef_seekShaderPass){this._predef_seekShaderPass(clampedTime)}if(!this.sceneObjects.tweens||this.sceneObjects.tweens.length===0){return}let notStartTweens=[];let runningTweens=[];let finishedTweens=[];for(let i=0;i<=this.sceneObjects.tweens.length-1;i++){const tween=this.sceneObjects.tweens[i];let TweenStartTime=tween._delayTime+10;let TweenEndTime=tween._delayTime+tween._duration;if(clampedTime<=TweenStartTime){notStartTweens.push({time:TweenStartTime,tween:tween})}else if(clampedTime>=TweenEndTime){finishedTweens.push({time:TweenEndTime,tween:tween})}else{runningTweens.push(tween)}}notStartTweens.sort((a,b)=>b.time-a.time);finishedTweens.sort((a,b)=>a.time-b.time);notStartTweens.forEach(item=>{this._applyTweenInitialState(item.tween)});finishedTweens.forEach(item=>{this._applyTweenFinalState(item.tween)});runningTweens.forEach(tween=>{tween.stop();tween.start(0);tween.update(clampedTime)});this.update()}setupSliders(){}updateSliders(){}setupScene(){this.initSceneObjects();this.setupSliders();this.updateSliders();this.scene.background=new THREE.Color(0);this.createPlane();this.setupAnimation();return this.sceneObjects}initSceneObjects(){this.sceneObjects={plane:null,material:null,tweens:[]}}createPlane(){const geometry=new THREE.PlaneGeometry(10,10,100,1);const material=this.createMaterial();this.sceneObjects.material=material;const plane=new THREE.Mesh(geometry,material);plane.name="Plane";this.sceneObjects.plane=plane;this.scene.add(plane)}createMaterial(){if(!this.texture1||!this.texture2){console.error("纹理未加载!");return new THREE.MeshBasicMaterial({color:16711680})}this.texture1.minFilter=THREE.LinearFilter;this.texture1.magFilter=THREE.LinearFilter;this.texture1.wrapS=THREE.ClampToEdgeWrapping;this.texture1.wrapT=THREE.ClampToEdgeWrapping;this.texture2.minFilter=THREE.LinearFilter;this.texture2.magFilter=THREE.LinearFilter;this.texture2.wrapS=THREE.ClampToEdgeWrapping;this.texture2.wrapT=THREE.ClampToEdgeWrapping;this.shaderPass=new(require("../pp/LumiCustom/CustomShaderPass.js").CustomShaderPass);var material=this.shaderPass.material;material.uniforms.tDiffuse.value=this.texture1;material.uniforms.tDiffuse1.value=this.texture2;return material}setupAnimation(){if(!this.shaderPass){console.error("着色器传递对象未创建!");return}if(typeof this.shaderPass.setParameter!=="function"){console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`);return}const duration=this.Duration;const tweens=[];this.sceneObjects.tweens=[];const tween1=new TWEEN.Tween({intensity:0,progress:0}).to({intensity:1,progress:.5},duration*.35).delay(duration*.15).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});const tween2=new TWEEN.Tween({intensity:1,progress:.5}).to({intensity:0,progress:1},duration*.35).delay(duration*.5).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});tweens.push(tween1,tween2);tweens.forEach(tween=>tween.start());if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}defaultUpdate(timestamp){if(this.sceneObjects.tweens&&this.sceneObjects.tweens.length>0){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.update==="function"){tween.update(timestamp)}})}this.update()}_predef_addTopCenterBottomStyleBorder(parent,offset,texture,cutoutAreaPosition,cutoutAreaSize){const aspectRatio=this.texture1.image.width/this.texture1.image.height;const parentInitScale=parent.scale.y;const parentPosition=parent.position;const textureWidth=texture.image.width;const textureHeight=texture.image.height;const geometry=new THREE.PlaneGeometry(10,10);const textureCenter=texture.clone();textureCenter.repeat.set(1,cutoutAreaSize.y/textureHeight);textureCenter.offset.set(0,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);const materialCenter=new THREE.MeshBasicMaterial({map:textureCenter,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialCenter.name="PlaneCenterMaterial";const planeCenter=new THREE.Mesh(geometry,materialCenter);planeCenter.name="PlaneCenter";planeCenter.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y,parentPosition.z+offset.z);planeCenter.scale.set(parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth),parentInitScale,1);this.scene.add(planeCenter);parent.attach(planeCenter);const textureTop=texture.clone();textureTop.repeat.set(1,cutoutAreaPosition.y/textureHeight);textureTop.offset.set(0,1-cutoutAreaPosition.y/textureHeight);const materialTop=new THREE.MeshBasicMaterial({map:textureTop,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialTop.name="PlaneTopMaterial";const scaleXTop=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYTop=scaleXTop*cutoutAreaPosition.y/textureWidth;const planeTop=new THREE.Mesh(geometry,materialTop);planeTop.name="PlaneTop";planeTop.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y+parentInitScale*10*.5+scaleYTop*10*.5,parentPosition.z+offset.z);planeTop.scale.set(scaleXTop,scaleYTop,1);this.scene.add(planeTop);parent.attach(planeTop);const textureBottom=texture.clone();textureBottom.repeat.set(1,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);textureBottom.offset.set(0,0);const materialBottom=new THREE.MeshBasicMaterial({map:textureBottom,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialBottom.name="PlaneBottomMaterial";const scaleXBottom=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYBottom=scaleXBottom*(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureWidth;const planeBottom=new THREE.Mesh(geometry,materialBottom);planeBottom.name="PlaneBottom";planeBottom.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y-parentInitScale*10*.5-scaleYBottom*10*.5,parentPosition.z+offset.z);planeBottom.scale.set(scaleXBottom,scaleYBottom,1);this.scene.add(planeBottom);parent.attach(planeBottom)}_predef_loadVideoTexture(path,loop,playbackRate){if(this.scene._amgScene==null){const video=document.createElement("video");video.src=path;video.muted=true;video.loop=loop;video.load();const videoTexture=new THREE.VideoTexture(video);videoTexture.currentTime=0;videoTexture.playbackRate=playbackRate;this.videoTexture=videoTexture;return videoTexture}else if(typeof this.scene._amgScene==="string"){return new THREE.Texture}else{const texture=new THREE.VideoTexture(path,loop,playbackRate);texture.load();return texture}}_predef_seekVideoTexture(time){if(this.videoTexture!=null){const videoTexture=this.videoTexture;const video=videoTexture.image;if(video.readyState>=2){const textureProperties=this.renderer.properties.get(videoTexture);var newTime=time/1e3*videoTexture.playbackRate;if(newTime<0){newTime=0}else if(newTime>video.duration){if(video.loop){newTime=newTime%video.duration}else{newTime=video.duration}}if(textureProperties.__version==videoTexture.version){videoTexture.currentTime=newTime;video.currentTime=videoTexture.currentTime}}}}_predef_seekShaderPass(time){if(!("shaderPasses"in this)||this.shaderPasses==null){return}this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="AnimSeqLoadAndCropBlendShaderPass"){if(this.texture1&&this.texture1.image){const ratio=this.texture1.image.width/this.texture1.image.height;if(typeof shaderPass.setAspectRatio==="function"){shaderPass.setAspectRatio(ratio)}}}})}}exports.ScriptScene=ScriptScene; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1 @@ +const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene,setCurrentScene,clearCurrentScene}=require("./wrapper/runtime");if(typeof window==="undefined"){const mockWindow={innerWidth:720,innerHeight:1280,devicePixelRatio:1,addEventListener:function(event,callback){},requestAnimationFrame:function(callback){},cancelAnimationFrame:function(id){},removeEventListener:function(event,callback){}};const mockDocument={createElement:function(tagName){return{style:{},setAttribute:function(){},appendChild:function(){}}},body:{appendChild:function(){}}};const getGlobalObject=function(){if(typeof global!=="undefined")return global;if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof this!=="undefined")return this;return{}};const globalObj=getGlobalObject();globalObj.window=mockWindow;globalObj.document=mockDocument;globalObj.cancelAnimationFrame=mockWindow.cancelAnimationFrame}const THREE={};const __THREE_CONSTS=require("./wrapper/Constants");THREE.FrontSide=__THREE_CONSTS.FrontSide;THREE.BackSide=__THREE_CONSTS.BackSide;THREE.DoubleSide=__THREE_CONSTS.DoubleSide;THREE.NoBlending=__THREE_CONSTS.NoBlending;THREE.NormalBlending=__THREE_CONSTS.NormalBlending;THREE.AdditiveBlending=__THREE_CONSTS.AdditiveBlending;THREE.SubtractiveBlending=__THREE_CONSTS.SubtractiveBlending;THREE.MultiplyBlending=__THREE_CONSTS.MultiplyBlending;THREE.CustomBlending=__THREE_CONSTS.CustomBlending;THREE.RepeatWrapping=__THREE_CONSTS.RepeatWrapping;THREE.ClampToEdgeWrapping=__THREE_CONSTS.ClampToEdgeWrapping;THREE.MirroredRepeatWrapping=__THREE_CONSTS.MirroredRepeatWrapping;const Vector2Wrapper=require("./wrapper/Vector2").Vector2;const Vector3Wrapper=require("./wrapper/Vector3").Vector3;const Vector4Wrapper=require("./wrapper/Vector4").Vector4;const EulerWrapper=require("./wrapper/Euler").Euler;const ColorWrapper=require("./wrapper/Color").Color;const Matrix4Wrapper=require("./wrapper/Matrix4").Matrix4;const QuaternionWrapper=require("./wrapper/Quaternion").Quaternion;const MathUtilsWrapper=require("./wrapper/MathUtils").MathUtils;const Box3Wrapper=require("./wrapper/Box3").Box3;const Box2Wrapper=require("./wrapper/Box2").Box2;const WebGLRendererWrapper=require("./wrapper/WebGLRenderer").WebGLRenderer;const Vector2=Vector2Wrapper;const Vector3=Vector3Wrapper;const Vector4=Vector4Wrapper;const Euler=EulerWrapper;const Color=ColorWrapper;const Matrix4=Matrix4Wrapper;const Quaternion=QuaternionWrapper;const MathUtils=MathUtilsWrapper;const Box3=Box3Wrapper;const Box2=Box2Wrapper;const WebGLRenderer=WebGLRendererWrapper;const BufferGeometryWrapper=require("./wrapper/BufferGeometry").BufferGeometry;const BufferAttributeWrapper=require("./wrapper/BufferAttribute").BufferAttribute;const BoxGeometryWrapper=require("./wrapper/BoxGeometry").BoxGeometry;const PlaneGeometryWrapper=require("./wrapper/PlaneGeometry").PlaneGeometry;const SphereGeometryWrapper=require("./wrapper/SphereGeometry").SphereGeometry;const CylinderGeometryWrapper=require("./wrapper/CylinderGeometry").CylinderGeometry;const CapsuleGeometryWrapper=require("./wrapper/CapsuleGeometry").CapsuleGeometry;const ShapeWrapper=require("./wrapper/Shape").Shape;const ShapeGeometryWrapper=require("./wrapper/ShapeGeometry").ShapeGeometry;const ExtrudeGeometryWrapper=require("./wrapper/ExtrudeGeometry").ExtrudeGeometry;const CurvePathWrapper=require("./wrapper/CurvePath").CurvePath;const LineCurveWrapper=require("./wrapper/CurvePath").LineCurve;const BufferGeometry=BufferGeometryWrapper;const BufferAttribute=BufferAttributeWrapper;const BoxGeometry=BoxGeometryWrapper;const PlaneGeometry=PlaneGeometryWrapper;const SphereGeometry=SphereGeometryWrapper;const CylinderGeometry=CylinderGeometryWrapper;const CapsuleGeometry=CapsuleGeometryWrapper;const Shape=ShapeWrapper;const ShapeGeometry=ShapeGeometryWrapper;const ExtrudeGeometry=ExtrudeGeometryWrapper;const CurvePath=CurvePathWrapper;const LineCurve=LineCurveWrapper;const TextureWrapper=require("./wrapper/Texture").Texture;const VideoTextureWrapper=require("./wrapper/Texture").VideoTexture;const TextureLoaderWrapper=require("./wrapper/Texture").TextureLoader;const Texture=TextureWrapper;const VideoTexture=VideoTextureWrapper;const TextureLoader=TextureLoaderWrapper;const MaterialWrapper=require("./wrapper/Material").Material;const MeshBasicMaterialWrapper=require("./wrapper/MeshBasicMaterial").MeshBasicMaterial;const ShaderMaterialWrapper=require("./wrapper/ShaderMaterial").ShaderMaterial;const Material=MaterialWrapper;const MeshBasicMaterial=MeshBasicMaterialWrapper;const ShaderMaterial=ShaderMaterialWrapper;const Object3DWrapper=require("./wrapper/Object3D").Object3D;const GroupWrapper=require("./wrapper/Group").Group;const MeshWrapper=require("./wrapper/Mesh").MeshWrapper;const PerspectiveCameraWrapper=require("./wrapper/PerspectiveCamera").PerspectiveCamera;const Object3D=Object3DWrapper;const Group=GroupWrapper;const Mesh=MeshWrapper;const PerspectiveCamera=PerspectiveCameraWrapper;class Scene{constructor(){this._objects=[];setCurrentScene(this);console.log("AMG scene created")}add(...objects){for(let i=0;iobj.update&&obj.update())}seekToTime(time){this._objects.forEach(obj=>obj.seekToTime&&obj.seekToTime(time))}dispose(){console.log("Scene: 开始清理场景资源");while(this._objects.length>0){const object=this._objects[0];this.delete(object);if(object.dispose&&typeof object.dispose==="function"){object.dispose()}if(object.geometry&&object.geometry.dispose){object.geometry.dispose()}if(object.material){if(Array.isArray(object.material)){object.material.forEach(material=>{if(material.dispose)material.dispose()})}else if(object.material.dispose){object.material.dispose()}}}if(this._amgScene){this._amgScene=null}this._objects=[];if(getCurrentScene()===this){clearCurrentScene()}console.log("Scene: 场景资源清理完成")}}class QuadraticBezierCurve3{constructor(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;return new Vector3(uu*this.p0.x+ut2*this.p1.x+tt*this.p2.x,uu*this.p0.y+ut2*this.p1.y+tt*this.p2.y,uu*this.p0.z+ut2*this.p1.z+tt*this.p2.z)}getPoints(divisions){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}}THREE.Vector2=Vector2;THREE.Vector3=Vector3;THREE.Vector4=Vector4;THREE.Euler=Euler;THREE.Color=Color;THREE.Matrix4=Matrix4;THREE.Quaternion=Quaternion;THREE.QuadraticBezierCurve3=QuadraticBezierCurve3;THREE.Box3=Box3;THREE.Box2=Box2;THREE.MathUtils=MathUtils;THREE.Scene=Scene;THREE.WebGLRenderer=WebGLRenderer;THREE.BufferGeometry=BufferGeometry;THREE.BufferAttribute=BufferAttribute;THREE.Float32BufferAttribute=BufferAttribute;THREE.BoxGeometry=BoxGeometry;THREE.PlaneGeometry=PlaneGeometry;THREE.SphereGeometry=SphereGeometry;THREE.CylinderGeometry=CylinderGeometry;THREE.CapsuleGeometry=CapsuleGeometry;THREE.Shape=Shape;THREE.ShapeGeometry=ShapeGeometry;THREE.ExtrudeGeometry=ExtrudeGeometry;THREE.CurvePath=CurvePath;THREE.LineCurve=LineCurve;THREE.Material=Material;THREE.MeshBasicMaterial=MeshBasicMaterial;THREE.ShaderMaterial=ShaderMaterial;THREE.Texture=Texture;THREE.VideoTexture=VideoTexture;THREE.TextureLoader=TextureLoader;THREE.Object3D=Group;THREE.Group=Group;THREE.Mesh=Mesh;THREE.PerspectiveCamera=PerspectiveCamera;exports.THREE=THREE;exports.getCurrentScene=getCurrentScene; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Easing=Object.freeze({Linear:Object.freeze({None:function(amount){return amount},In:function(amount){return amount},Out:function(amount){return amount},InOut:function(amount){return amount}}),Quadratic:Object.freeze({In:function(amount){return amount*amount},Out:function(amount){return amount*(2-amount)},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount}return-.5*(--amount*(amount-2)-1)}}),Cubic:Object.freeze({In:function(amount){return amount*amount*amount},Out:function(amount){return--amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount}return.5*((amount-=2)*amount*amount+2)}}),Quartic:Object.freeze({In:function(amount){return amount*amount*amount*amount},Out:function(amount){return 1- --amount*amount*amount*amount},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount}return-.5*((amount-=2)*amount*amount*amount-2)}}),Quintic:Object.freeze({In:function(amount){return amount*amount*amount*amount*amount},Out:function(amount){return--amount*amount*amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount*amount}return.5*((amount-=2)*amount*amount*amount*amount+2)}}),Sinusoidal:Object.freeze({In:function(amount){return 1-Math.sin((1-amount)*Math.PI/2)},Out:function(amount){return Math.sin(amount*Math.PI/2)},InOut:function(amount){return.5*(1-Math.sin(Math.PI*(.5-amount)))}}),Exponential:Object.freeze({In:function(amount){return amount===0?0:Math.pow(1024,amount-1)},Out:function(amount){return amount===1?1:1-Math.pow(2,-10*amount)},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}if((amount*=2)<1){return.5*Math.pow(1024,amount-1)}return.5*(-Math.pow(2,-10*(amount-1))+2)}}),Circular:Object.freeze({In:function(amount){return 1-Math.sqrt(1-amount*amount)},Out:function(amount){return Math.sqrt(1- --amount*amount)},InOut:function(amount){if((amount*=2)<1){return-.5*(Math.sqrt(1-amount*amount)-1)}return.5*(Math.sqrt(1-(amount-=2)*amount)+1)}}),Elastic:Object.freeze({In:function(amount){if(amount===0){return 0}if(amount===1){return 1}return-Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)},Out:function(amount){if(amount===0){return 0}if(amount===1){return 1}return Math.pow(2,-10*amount)*Math.sin((amount-.1)*5*Math.PI)+1},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}amount*=2;if(amount<1){return-.5*Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)}return.5*Math.pow(2,-10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)+1}}),Back:Object.freeze({In:function(amount){var s=1.70158;return amount===1?1:amount*amount*((s+1)*amount-s)},Out:function(amount){var s=1.70158;return amount===0?0:--amount*amount*((s+1)*amount+s)+1},InOut:function(amount){var s=1.70158*1.525;if((amount*=2)<1){return.5*(amount*amount*((s+1)*amount-s))}return.5*((amount-=2)*amount*((s+1)*amount+s)+2)}}),Bounce:Object.freeze({In:function(amount){return 1-Easing.Bounce.Out(1-amount)},Out:function(amount){if(amount<1/2.75){return 7.5625*amount*amount}else if(amount<2/2.75){return 7.5625*(amount-=1.5/2.75)*amount+.75}else if(amount<2.5/2.75){return 7.5625*(amount-=2.25/2.75)*amount+.9375}else{return 7.5625*(amount-=2.625/2.75)*amount+.984375}},InOut:function(amount){if(amount<.5){return Easing.Bounce.In(amount*2)*.5}return Easing.Bounce.Out(amount*2-1)*.5+.5}}),generatePow:function(power){if(power===void 0){power=4}power=power1e4?1e4:power;return{In:function(amount){return Math.pow(amount,power)},Out:function(amount){return 1-Math.pow(1-amount,power)},InOut:function(amount){if(amount<.5){return Math.pow(amount*2,power)/2}return(1-Math.pow(2-amount*2,power))/2+.5}}}});var now=function(){if(typeof process!=="undefined"&&process.hrtime){if(!now._nodeStartTime){now._nodeStartTime=process.hrtime()}var hrTime=process.hrtime(now._nodeStartTime);return hrTime[0]*1e3+hrTime[1]/1e6}if(typeof now._startTime==="undefined"){now._startTime=Date.now();now._lastReturned=0}var elapsed=Date.now()-now._startTime;if(elapsed<=now._lastReturned){now._lastReturned+=.001}else{now._lastReturned=elapsed}return now._lastReturned};function setNow(nowFunction){_nowFunc=nowFunction}var Group=function(){function Group(){var tweens=[];for(var _i=0;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){return fn(v[m],v[m-1],m-f)}return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0;var n=v.length-1;var pw=Math.pow;var bn=Interpolation.Utils.Bernstein;for(var i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0){i=Math.floor(f=m*(1+k))}return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0){return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0])}if(k>1){return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m])}return fn(v[i?i-1:0],v[i],v[m1;i--){s*=i}a[n]=s;return s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5;var v1=(p3-p1)*.5;var t2=t*t;var t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var Sequence=function(){function Sequence(){}Sequence.nextId=function(){return Sequence._nextId++};Sequence._nextId=0;return Sequence}();var mainGroup=new Group;var Tween=function(){function Tween(object,group){this._isPaused=false;this._pauseStart=0;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1e3;this._isDynamic=false;this._initialRepeat=0;this._repeat=0;this._yoyo=false;this._isPlaying=false;this._reversed=false;this._delayTime=0;this._startTime=0;this._easingFunction=Easing.Linear.None;this._interpolationFunction=Interpolation.Linear;this._chainedTweens=[];this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._id=Sequence.nextId();this._isChainStopped=false;this._propertiesAreSetUp=false;this._goToEnd=false;this._object=object;if(typeof group==="object"){this._group=group;group.add(this)}else if(group===true){this._group=mainGroup;mainGroup.add(this)}}Tween.prototype.getId=function(){return this._id};Tween.prototype.getCompleteCallback=function(){return this._onCompleteCallback};Tween.prototype.isPlaying=function(){return this._isPlaying};Tween.prototype.isPaused=function(){return this._isPaused};Tween.prototype.getDuration=function(){return this._duration};Tween.prototype.to=function(target,duration){if(duration===void 0){duration=1e3}if(this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");this._valuesEnd=target;this._propertiesAreSetUp=false;this._duration=duration<0?0:duration;return this};Tween.prototype.duration=function(duration){if(duration===void 0){duration=1e3}this._duration=duration<0?0:duration;return this};Tween.prototype.dynamic=function(dynamic){if(dynamic===void 0){dynamic=false}this._isDynamic=dynamic;return this};Tween.prototype.start=function(time,overrideStartingValues){if(time===void 0){time=now()}if(overrideStartingValues===void 0){overrideStartingValues=false}if(this._isPlaying){return this}this._repeat=this._initialRepeat;if(this._reversed){this._reversed=false;for(var property in this._valuesStartRepeat){this._swapEndStartRepeatValues(property);this._valuesStart[property]=this._valuesStartRepeat[property]}}this._isPlaying=true;this._isPaused=false;this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._isChainStopped=false;this._startTime=time;this._startTime+=this._delayTime;if(!this._propertiesAreSetUp||overrideStartingValues){this._propertiesAreSetUp=true;if(!this._isDynamic){var tmp={};for(var prop in this._valuesEnd)tmp[prop]=this._valuesEnd[prop];this._valuesEnd=tmp}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,overrideStartingValues)}return this};Tween.prototype.startFromCurrentValues=function(time){return this.start(time,true)};Tween.prototype._setupProperties=function(_object,_valuesStart,_valuesEnd,_valuesStartRepeat,overrideStartingValues){for(var property in _valuesEnd){var startValue=_object[property];var startValueIsArray=Array.isArray(startValue);var propType=startValueIsArray?"array":typeof startValue;var isInterpolationList=!startValueIsArray&&Array.isArray(_valuesEnd[property]);if(propType==="undefined"||propType==="function"){continue}if(isInterpolationList){var endValues=_valuesEnd[property];if(endValues.length===0){continue}var temp=[startValue];for(var i=0,l=endValues.length;itotalTime){return 1}var timesRepeated=Math.trunc(elapsedTime/durationAndDelay);var timeIntoCurrentRepeat=elapsedTime-timesRepeated*durationAndDelay;var portion=Math.min(timeIntoCurrentRepeat/_this._duration,1);if(portion===0&&elapsedTime===_this._duration){return 1}return portion};var elapsed=calculateElapsedPortion();var value=this._easingFunction(elapsed);this._updateProperties(this._object,this._valuesStart,this._valuesEnd,value);if(this._onUpdateCallback){this._onUpdateCallback(this._object,elapsed)}if(this._duration===0||elapsedTime>=this._duration){if(this._repeat>0){var completeCount=Math.min(Math.trunc((elapsedTime-this._duration)/durationAndDelay)+1,this._repeat);if(isFinite(this._repeat)){this._repeat-=completeCount}for(property in this._valuesStartRepeat){if(!this._yoyo&&typeof this._valuesEnd[property]==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(this._valuesEnd[property])}if(this._yoyo){this._swapEndStartRepeatValues(property)}this._valuesStart[property]=this._valuesStartRepeat[property]}if(this._yoyo){this._reversed=!this._reversed}this._startTime+=durationAndDelay*completeCount;if(this._onRepeatCallback){this._onRepeatCallback(this._object)}this._onEveryStartCallbackFired=false;return true}else{if(this._onCompleteCallback){this._onCompleteCallback(this._object)}for(var i=0,numChainedTweens=this._chainedTweens.length;ithis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x) 0.0001 ? centered / radius : vec2(0.0, 1.0); + vec2 curlOffset = dir * max(0.0, -shape) * (0.09 + 0.04 * sin(angle * 2.0 + open * 3.1415926)) * bloom; + vec2 curlUV = uv + vec2(curlOffset.x / ratio, curlOffset.y); + vec2 pushUV = (uv - 0.5) * (1.0 - 0.035 * open) + 0.5; + + vec4 revealSample = texture2D(tDiffuse1, clamp(curlUV, 0.0, 1.0)); + vec4 pushSample = texture2D(tDiffuse1, clamp(pushUV, 0.0, 1.0)); + vec3 revealColor = mix(revealSample.rgb, pushSample.rgb, clamp(open * 0.45 + snap * 0.25, 0.0, 1.0)); + + float grain = grainPattern(centered * 7.0 + open * 3.2); + vec3 paperTint = mix(texel1.rgb, vec3(0.95, 0.92, 0.88), 0.65); + paperTint *= 0.93 + 0.07 * grain; + + float flapLift = clamp((-shape) / (edgeWidth * 5.0), 0.0, 1.0) * outsideMask * bloom; + vec3 undersideTint = mix(vec3(0.72, 0.68, 0.63), vec3(0.58, 0.54, 0.5), sin(angle * 2.7) * 0.5 + 0.5); + vec3 curledPaper = mix(paperTint, undersideTint, flapLift); + + float innerShadow = clamp(edgeWidth * 0.9 - shape, 0.0, edgeWidth * 0.9) / (edgeWidth * 0.9 + 1e-6); + innerShadow = pow(innerShadow, 1.5); + vec3 innerColor = revealColor * (1.0 - 0.28 * innerShadow) + vec3(0.08) * innerShadow; + innerColor *= 1.0 + 0.12 * snap; + + float fiberMask = pow(clamp(1.0 - abs(shape) / (edgeWidth * 1.1 + 1e-6), 0.0, 1.0), mix(5.0, 3.0, tearSharpness)); + vec2 fiberCoord = vec2(hash12(floor(centered * 180.0)), hash12(floor(centered.yx * 150.0))); + float fiberNoise = (fiberCoord.x + fiberCoord.y) * 0.5 - 0.25; + vec3 fiberColor = vec3(0.12, 0.11, 0.1) * fiberMask * (0.6 + 1.2 * fiberNoise); + vec3 paperWithFibers = curledPaper + fiberColor; + + vec2 debrisGrid = floor((centered * vec2(40.0, 28.0) + 0.5) * (0.8 + open * 1.6)); + float debrisSeed = hash12(debrisGrid + floor(progress * 24.0)); + float debrisGate = step(0.965, debrisSeed); + vec2 debrisFrac = fract((centered * vec2(40.0, 28.0) + 0.5) * (0.8 + open * 1.6)) - 0.5; + float debrisShape = smoothstep(0.36, 0.08, length(debrisFrac)); + float debrisLife = smoothstep(0.18, 0.62, progress) * (1.0 - smoothstep(0.85, 1.0, progress)); + float debris = debrisGate * debrisShape * debrisLife * openMask; + vec3 debrisColor = vec3(0.18, 0.17, 0.15) * debris * (0.4 + 0.6 * hash12(debrisGrid + 7.3)); + + vec3 combined = mix(paperWithFibers, innerColor, openMask); + combined += debrisColor; + combined = clamp(combined, 0.0, 1.0); + + float snapHighlight = smoothstep(0.92, 1.0, progress) * openMask; + combined = mix(combined, revealColor, snapHighlight * 0.3); + + float finalAlpha = mix(texel1.a, texel2.a, openMask); + finalAlpha = clamp(finalAlpha, 0.0, 1.0); + + return vec4(combined, finalAlpha); +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681274733958122770/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file diff --git a/scripts/7681274733958122770/AmazingFeature/xshader/Unlit.frag b/scripts/7681274733958122770/AmazingFeature/xshader/Unlit.frag new file mode 100644 index 0000000000000000000000000000000000000000..2b8ef6c235afd5362d14d87961e5b7fa2fe044b1 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/xshader/Unlit.frag @@ -0,0 +1,25 @@ +precision highp float; +uniform sampler2D u_AlbedoTexture; +uniform vec4 u_AlbedoColor; +uniform vec2 u_Repeat; +uniform vec2 u_Offset; +uniform float u_Translucency; +uniform float u_Opacity; +varying vec2 g_vary_uv0; +void main () +{ + vec2 uv_1; + uv_1.x = g_vary_uv0.x; + uv_1.y = (g_vary_uv0.y); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (u_AlbedoTexture, (uv_1 * u_Repeat + u_Offset)); + lowp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2.xyz * u_AlbedoColor.xyz); + lowp float tmpvar_4; + tmpvar_4 = (tmpvar_2.w * u_Translucency); + mediump vec4 tmpvar_5; + tmpvar_5.xyz = tmpvar_3; + tmpvar_5.w = tmpvar_4; + gl_FragColor = vec4(tmpvar_5.xyz * u_Opacity, tmpvar_5.w * u_Opacity); +} + diff --git a/scripts/7681274733958122770/AmazingFeature/xshader/Unlit.vert b/scripts/7681274733958122770/AmazingFeature/xshader/Unlit.vert new file mode 100644 index 0000000000000000000000000000000000000000..64a27d816e6146a0fb85643a9991207e5fda2acb --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/xshader/Unlit.vert @@ -0,0 +1,35 @@ +precision highp float; +attribute vec3 attPosition; +attribute vec2 attTexcoord0; + +//#define AMAZING_USE_BONES + +#ifdef AMAZING_USE_BONES +attribute vec4 attBoneIds; +attribute vec4 attWeights; +const int MAX_BONES = 50; +uniform mat4 u_Palatte[MAX_BONES]; +#endif + +uniform mat4 u_Model; +uniform mat4 u_MVP; +varying vec2 g_vary_uv0; + + + +void main () +{ + vec3 modelPostiton = attPosition; + vec4 homogeneous_pos = vec4(attPosition, 1.0); + g_vary_uv0 = attTexcoord0; + +#ifdef AMAZING_USE_BONES + mat4 boneTransform = u_Palatte[int(attBoneIds.x)] * attWeights.x; + boneTransform += u_Palatte[int(attBoneIds.y)] * attWeights.y; + boneTransform += u_Palatte[int(attBoneIds.z)] * attWeights.z; + boneTransform += u_Palatte[int(attBoneIds.w)] * attWeights.w; + gl_Position = u_MVP * boneTransform * homogeneous_pos; +#else + gl_Position = u_MVP * homogeneous_pos; +#endif +} diff --git a/scripts/7681274733958122770/AmazingFeature/xshader/noface.frag b/scripts/7681274733958122770/AmazingFeature/xshader/noface.frag new file mode 100644 index 0000000000000000000000000000000000000000..88e9ec343761b2395bae9430e6e55466b0367d67 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/xshader/noface.frag @@ -0,0 +1,7 @@ +precision lowp float; +varying highp vec2 uv0; +uniform sampler2D u_albedo; +void main() +{ + gl_FragColor = texture2D(u_albedo, uv0); +} diff --git a/scripts/7681274733958122770/AmazingFeature/xshader/noface.vert b/scripts/7681274733958122770/AmazingFeature/xshader/noface.vert new file mode 100644 index 0000000000000000000000000000000000000000..16450a4b5880cf8d83528ea1ae0f47d10b2ab1d8 --- /dev/null +++ b/scripts/7681274733958122770/AmazingFeature/xshader/noface.vert @@ -0,0 +1,12 @@ +precision highp float; + +attribute vec2 position; +attribute vec2 texcoord0; +varying vec2 uv0; +//uniform mat4 u_MVP; +void main() +{ + //gl_Position = u_MVP * position; + gl_Position = sign(vec4(position.xy, 0.0, 1.0)); + uv0 = texcoord0; +} diff --git a/scripts/7681274733958122770/config.json b/scripts/7681274733958122770/config.json new file mode 100644 index 0000000000000000000000000000000000000000..557ff9895b4c8c8a7d91baae310b40001cd6c20d --- /dev/null +++ b/scripts/7681274733958122770/config.json @@ -0,0 +1,16 @@ +{ + "ae_tool": "AmazingEditor", + "bALG_BACH_CONFIG": false, + "effect": { + "Link": [ + { + "path": "AmazingFeature/", + "type": "AmazingFeature", + "zorder": 8011 + } + ] + }, + "name": "AlgorithmGraph_7bdbHcdcscQkbEdcc9cIlcNdvTdtb", + "version": "13.4.0", + "item_source": "user_post_pc_lumi_ai" +} \ No newline at end of file diff --git a/scripts/7681274733958122770/extra.json b/scripts/7681274733958122770/extra.json new file mode 100644 index 0000000000000000000000000000000000000000..77d32b6df4ccdfb83b17fec1ccccce97826d117f --- /dev/null +++ b/scripts/7681274733958122770/extra.json @@ -0,0 +1,27 @@ +{ + "transition": { + "defaultDura": 2.0, + "isOverlap": true + }, + "External_Producer": true, + "setting": { + "lumiai_material_properties": [ + { + "effect_key": "progress", + "effect_key_cn": "progress", + "type": "float", + "default": 0, + "min": 0, + "max": 1 + }, + { + "effect_key": "tearSharpness", + "effect_key_cn": "tearSharpness", + "type": "float", + "default": 0.6, + "min": 0.2, + "max": 1 + } + ] + } +} \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/content.json b/scripts/7681278636074355976/AmazingFeature/content.json new file mode 100644 index 0000000000000000000000000000000000000000..df43720515b1b6981b24c4268c902195fa613d43 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/content.json @@ -0,0 +1,7 @@ +{ + "ae_tool" : "AmazingEditor", + "content" : {}, + "needblend" : false, + "tag" : "AMG_1515088281693380358513659446614427937212", + "version" : "1.0" +} \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/JSSys.js b/scripts/7681278636074355976/AmazingFeature/js/JSSys.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcbf36f0f75c1beebe88c33dd0464bb4477158e --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/JSSys.js @@ -0,0 +1,89 @@ +const effect_api = "undefined" != typeof effect ? effect : "undefined" != typeof tt ? tt : "undefined" != typeof lynx ? lynx : {}; +const Amaz = effect_api.getAmaz(); + +const { ScriptScene } = require('./ThreeJS/scriptScene'); +const THREE = require('./ThreeJS/three-amg-wrapper').THREE; + +class JSSys { + constructor() { + this.name = "JSSys"; + this.comps = {} + this.compsdirty = true + } + + onComponentAdded(comp) { + // console.log("running:JSSys:onComponentAdded"); + } + onComponentRemoved(comp) { + // console.log("running:JSSys:onComponentRemoved"); + } + + onStart() { + console.log("running:JSSys:onStart"); + + this.renderTexture = this.scene.assetMgr.SyncLoad('rt/outputTex.rt'); + + // 添加光源到场景 + console.log('JSSys: 创建ScriptScene实例'); + this.scriptScene = new ScriptScene(this.scene); + + this.input = Amaz.AmazingManager.getSingleton("Input"); + const builtinObject = Amaz.AmazingManager.getSingleton("BuiltinObject"); + + if (builtinObject.getUserTexture("#TransitionInput0") && builtinObject.getUserTexture("#TransitionInput1")) { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(builtinObject.getUserTexture("#TransitionInput0")); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(builtinObject.getUserTexture("#TransitionInput1")); + console.log("JSSys: 获取到纹理"); + } + else + { + this.scriptScene.texture1 = new THREE.Texture(); + this.scriptScene.texture1.setImage(this.scene.assetMgr.SyncLoad('image/Sample1.jpg')); + this.scriptScene.texture2 = new THREE.Texture(); + this.scriptScene.texture2.setImage(this.scene.assetMgr.SyncLoad('image/Sample2.jpg')); + console.log("JSSys: 未获取到纹理,使用默认纹理"); + } + + this.scriptScene.setupScene(); + // 初始化后处理效果 + if (this.scriptScene.initPostProcessing != null) { + this.scriptScene.initPostProcessing(); + } + } + + onUpdate(deltaTime) { + this.time = this.input.getFrameTimestamp(); + // this.time = this.time % 2; + // this.time = this.time / 2.0; + this.scriptScene.seekToTime(this.time * this.scriptScene.Duration); + // this.scriptScene.updateScene(); + } + onLateUpdate(deltaTime) { + // console.log("running:JSSys:onLateUpdate"); + this.scriptScene.scene.seekToTime(this.time * this.scriptScene.Duration); + } + + onEvent(event) { + console.log("running:JSSys:onEvent"); + if (event.type == Amaz.EventType.VIEWER) { + // console.log("JSSys: 窗口大小改变"); + console.log("renderTexture.width",this.renderTexture.width); + console.log("renderTexture.height",this.renderTexture.height); + + window.innerWidth = this.renderTexture.width; + window.innerHeight = this.renderTexture.height; + // console.log("JSSys: 窗口大小改变"); + this.scriptScene.handleResize(); + } + } + + onDestroy() { + // console.log("running:JSSys:onDestroy"); + this.scriptScene.destroy(); + } +} + +exports.JSSys = JSSys; + diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/EffectComposer.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/EffectComposer.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d8fd7a3f3978d9da1a9bf29af1854806f60014 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/EffectComposer.js @@ -0,0 +1 @@ +const{ShaderPass}=require("./ShaderPass.js");const getCurrentScene=require("./three-amg-wrapper.js").getCurrentScene;const RenderPass=require("./RenderPass.js").RenderPass;const Texture=require("./wrapper/Texture").Texture;const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class EffectComposer{constructor(renderer){this.renderer=renderer;this.passes=[];this.scene=getCurrentScene();this.rt_0=this.scene._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this.rt_prev_Texture=null;this.rt_next_Texture=null;this.sourceEntity=this.scene._amgScene.findEntityBy("PerspectiveCamera_w");this.sourceCamera=this.sourceEntity?this.sourceEntity.getComponent("Camera"):null;this.outputEntity=this.scene._amgScene.findEntityBy("Camera")||this.sourceEntity;this.outputCamera=this.outputEntity?this.outputEntity.getComponent("Camera"):null;this._outputIsPerspective=!!(this.outputEntity&&this.outputEntity.name==="PerspectiveCamera_w");this._initialInputTexture=this.rt_0;this._currentInputTexture=this._initialInputTexture;this._ppPassCount=0;this.finalPlaceHolder=this.scene._amgScene.findEntityBy("PlaceHolder");this.outputRT=this.scene._amgScene.assetMgr.SyncLoad("rt/outputTex.rt");if(this.sourceEntity){this.sourceEntity.layer=0;if(this.sourceCamera){this.sourceCamera.renderOrder=0;this.sourceCamera.renderTexture=this.rt_0}}}_getStartOrder(){let startOrder=0;for(let i=0;i{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5f0a8bde54f7efa0912b77bb0a8298e3fb04e9 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1 @@ +const TWEEN=require("./tween");const customEasings=require("./customEasings").customEasings;const THREE=require("./three-amg-wrapper").THREE;const{ShaderPass}=require("./ShaderPass.js");class ScriptScene{constructor(amgScene=null,container=null){if(amgScene){this.scene=new THREE.Scene;this.scene._amgScene=amgScene}else{this.scene=new THREE.Scene}this.effect_type="transition";this.camera=null;this.renderer=null;this.scene.background=new THREE.Color(3355443);this.isAnimating=false;this.animationFrameId=null;this.sceneObjects=null;this.texture1=null;this.texture2=null;this.composer=null;this.renderPass=null;this.usePostProcessing=true;this.initCoreObjects();if(container){this.init(container)}}destroy(){this.isAnimating=false;if(this.animationFrameId!==null&&typeof cancelAnimationFrame!=="undefined"){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}if(this.renderer){this.renderer.setAnimationLoop(null);this.renderer.dispose();if(this.renderer.domElement&&this.renderer.domElement.parentNode){this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}if(this.texture1){if(typeof this.texture1.dispose==="function")this.texture1.dispose();this.texture1=null}if(this.texture2){if(typeof this.texture2.dispose==="function")this.texture2.dispose();this.texture2=null}if(this.scene){this.scene.dispose()}if(typeof window!=="undefined"){window.removeEventListener("resize",this.handleResize)}if(this.sceneObjects&&this.sceneObjects.tweens){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.stop==="function"){tween.stop()}});this.sceneObjects.tweens=[]}if(this.shaderPasses&&this.shaderPasses.length){this.shaderPasses.forEach(pass=>{if(pass&&typeof pass.dispose==="function"){try{pass.dispose()}catch(e){}}});this.shaderPasses=[]}if(this.shaderPass&&typeof this.shaderPass.dispose==="function"){try{this.shaderPass.dispose()}catch(e){}}this.shaderPass=null;if(this.composer){this.composer.dispose();this.composer=null}this.renderPass=null;this.scene=null;this.camera=null;this.renderer=null;this.sceneObjects=null}initCoreObjects(){if(typeof window!=="undefined"){if(!window.innerWidth||!window.innerHeight){window.innerWidth=600;window.innerHeight=600}window.devicePixelRatio=window.devicePixelRatio||1;if(this.scene&&this.scene._amgScene&&this.scene._amgScene.assetMgr){const inputTexture=this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");if(inputTexture&&inputTexture.width>0&&inputTexture.height>0){window.innerWidth=inputTexture.width;window.innerHeight=inputTexture.height}}}this.camera=new THREE.PerspectiveCamera(53.1,window.innerWidth/window.innerHeight,.1,1e4);this.camera.position.z=10;this.scene.add(this.camera);if(this.scene._amgScene==null){this.renderer=new THREE.WebGLRenderer({antialias:true});this.renderer.outputColorSpace=THREE.LinearSRGBColorSpace}if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight);this.renderer.setPixelRatio(window.devicePixelRatio)}this.sliders={};this.TWEEN=TWEEN;this.customEasings=customEasings;this.Duration=2e3}addShaderPass(shaderPassConfigs){if(!Array.isArray(shaderPassConfigs)){shaderPassConfigs=[shaderPassConfigs]}shaderPassConfigs.forEach(config=>{const atomicName=config.name;const className=atomicName.startsWith("Lumi")?atomicName.substring(4):atomicName;const shaderPassModule=require("../pp/Lumi"+className+"/"+className+"ShaderPass.js");const ShaderPassClass=shaderPassModule[className+"ShaderPass"];const initConfig=config&&(config.initConfig||config.config||config.params)||{};const shaderPass=new ShaderPassClass(initConfig);this.composer.addPass(shaderPass);this.shaderPasses.push(shaderPass)})}setupPostProcessing(shaderPassConfigs){const{EffectComposer}=require("./EffectComposer.js");const{RenderPass}=require("./RenderPass.js");this.composer=new EffectComposer(this.renderer);this.renderPass=new RenderPass(this.scene,this.camera);this.composer.addPass(this.renderPass);this.shaderPasses=[];this.addShaderPass(shaderPassConfigs)}initPostProcessing(){}init(container){if(this.renderer){if(container){container.appendChild(this.renderer.domElement)}else if(typeof document!=="undefined"){document.body.appendChild(this.renderer.domElement)}}if(typeof window!=="undefined"){window.addEventListener("resize",()=>this.handleResize())}}start(updateCallback){if(this.isAnimating)return;this.isAnimating=true;if(updateCallback){const animateFrame=()=>{if(!this.isAnimating)return;updateCallback();this.animationFrameId=requestAnimationFrame(animateFrame)};animateFrame()}else{this.renderer.setAnimationLoop(()=>{this.update()})}}updateScene(timestamp){if(!this.isAnimating){this.isAnimating=true}this.defaultUpdate(timestamp)}update(){if(this.usePostProcessing&&this.composer){if(this.renderPass){this.renderPass.camera=this.camera}this.composer.render()}else if(this.renderer){this.renderer.render(this.scene,this.camera)}}handleResize(){this.camera.aspect=window.innerWidth/window.innerHeight;this.camera.updateProjectionMatrix();if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight)}if(!this.isAnimating){this.update()}}loadTextures(){const textureLoader=new THREE.TextureLoader;return Promise.all([new Promise(resolve=>{this.texture1=textureLoader.load("image/Sample1.jpg",resolve);this.texture1.colorSpace=THREE.LinearSRGBColorSpace;this.texture1.wrapS=THREE.RepeatWrapping;this.texture1.wrapT=THREE.RepeatWrapping}),new Promise(resolve=>{this.texture2=textureLoader.load("image/Sample2.jpg",resolve);this.texture2.colorSpace=THREE.LinearSRGBColorSpace;this.texture2.wrapS=THREE.RepeatWrapping;this.texture2.wrapT=THREE.RepeatWrapping})])}_applyTweenInitialState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,0);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,0)}}_applyTweenFinalState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,1);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,1)}}seekToTime(time){if(!this.isAnimating){this.isAnimating=true}const clampedTime=Math.max(0,Math.min(time,this.Duration));if(this._predef_seekShaderPass){this._predef_seekShaderPass(clampedTime)}if(!this.sceneObjects.tweens||this.sceneObjects.tweens.length===0){return}let notStartTweens=[];let runningTweens=[];let finishedTweens=[];for(let i=0;i<=this.sceneObjects.tweens.length-1;i++){const tween=this.sceneObjects.tweens[i];let TweenStartTime=tween._delayTime+10;let TweenEndTime=tween._delayTime+tween._duration;if(clampedTime<=TweenStartTime){notStartTweens.push({time:TweenStartTime,tween:tween})}else if(clampedTime>=TweenEndTime){finishedTweens.push({time:TweenEndTime,tween:tween})}else{runningTweens.push(tween)}}notStartTweens.sort((a,b)=>b.time-a.time);finishedTweens.sort((a,b)=>a.time-b.time);notStartTweens.forEach(item=>{this._applyTweenInitialState(item.tween)});finishedTweens.forEach(item=>{this._applyTweenFinalState(item.tween)});runningTweens.forEach(tween=>{tween.stop();tween.start(0);tween.update(clampedTime)});this.update()}setupSliders(){}updateSliders(){}setupScene(){this.initSceneObjects();this.setupSliders();this.updateSliders();this.scene.background=new THREE.Color(0);this.createPlane();this.setupAnimation();return this.sceneObjects}initSceneObjects(){this.sceneObjects={plane:null,material:null,tweens:[]}}createPlane(){const geometry=new THREE.PlaneGeometry(10,10,100,1);const material=this.createMaterial();this.sceneObjects.material=material;const plane=new THREE.Mesh(geometry,material);plane.name="Plane";this.sceneObjects.plane=plane;this.scene.add(plane)}createMaterial(){if(!this.texture1||!this.texture2){console.error("纹理未加载!");return new THREE.MeshBasicMaterial({color:16711680})}this.texture1.minFilter=THREE.LinearFilter;this.texture1.magFilter=THREE.LinearFilter;this.texture1.wrapS=THREE.ClampToEdgeWrapping;this.texture1.wrapT=THREE.ClampToEdgeWrapping;this.texture2.minFilter=THREE.LinearFilter;this.texture2.magFilter=THREE.LinearFilter;this.texture2.wrapS=THREE.ClampToEdgeWrapping;this.texture2.wrapT=THREE.ClampToEdgeWrapping;this.shaderPass=new(require("../pp/LumiCustom/CustomShaderPass.js").CustomShaderPass);var material=this.shaderPass.material;material.uniforms.tDiffuse.value=this.texture1;material.uniforms.tDiffuse1.value=this.texture2;return material}setupAnimation(){if(!this.shaderPass){console.error("着色器传递对象未创建!");return}if(typeof this.shaderPass.setParameter!=="function"){console.error(`${this.shaderPass.constructor.name} 中没有 setParameter 方法`);return}const duration=this.Duration;const tweens=[];this.sceneObjects.tweens=[];const tween1=new TWEEN.Tween({intensity:0,progress:0}).to({intensity:1,progress:.5},duration*.35).delay(duration*.15).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});const tween2=new TWEEN.Tween({intensity:1,progress:.5}).to({intensity:0,progress:1},duration*.35).delay(duration*.5).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{for(const key in obj){this.shaderPass.setParameter(key,obj[key])}});tweens.push(tween1,tween2);tweens.forEach(tween=>tween.start());if(tweens.length>0){if(!this.sceneObjects.tweens){this.sceneObjects.tweens=[]}this.sceneObjects.tweens.push(...tweens)}}defaultUpdate(timestamp){if(this.sceneObjects.tweens&&this.sceneObjects.tweens.length>0){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.update==="function"){tween.update(timestamp)}})}this.update()}_predef_addTopCenterBottomStyleBorder(parent,offset,texture,cutoutAreaPosition,cutoutAreaSize){const aspectRatio=this.texture1.image.width/this.texture1.image.height;const parentInitScale=parent.scale.y;const parentPosition=parent.position;const textureWidth=texture.image.width;const textureHeight=texture.image.height;const geometry=new THREE.PlaneGeometry(10,10);const textureCenter=texture.clone();textureCenter.repeat.set(1,cutoutAreaSize.y/textureHeight);textureCenter.offset.set(0,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);const materialCenter=new THREE.MeshBasicMaterial({map:textureCenter,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialCenter.name="PlaneCenterMaterial";const planeCenter=new THREE.Mesh(geometry,materialCenter);planeCenter.name="PlaneCenter";planeCenter.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y,parentPosition.z+offset.z);planeCenter.scale.set(parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth),parentInitScale,1);this.scene.add(planeCenter);parent.attach(planeCenter);const textureTop=texture.clone();textureTop.repeat.set(1,cutoutAreaPosition.y/textureHeight);textureTop.offset.set(0,1-cutoutAreaPosition.y/textureHeight);const materialTop=new THREE.MeshBasicMaterial({map:textureTop,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialTop.name="PlaneTopMaterial";const scaleXTop=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYTop=scaleXTop*cutoutAreaPosition.y/textureWidth;const planeTop=new THREE.Mesh(geometry,materialTop);planeTop.name="PlaneTop";planeTop.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y+parentInitScale*10*.5+scaleYTop*10*.5,parentPosition.z+offset.z);planeTop.scale.set(scaleXTop,scaleYTop,1);this.scene.add(planeTop);parent.attach(planeTop);const textureBottom=texture.clone();textureBottom.repeat.set(1,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);textureBottom.offset.set(0,0);const materialBottom=new THREE.MeshBasicMaterial({map:textureBottom,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialBottom.name="PlaneBottomMaterial";const scaleXBottom=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYBottom=scaleXBottom*(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureWidth;const planeBottom=new THREE.Mesh(geometry,materialBottom);planeBottom.name="PlaneBottom";planeBottom.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y-parentInitScale*10*.5-scaleYBottom*10*.5,parentPosition.z+offset.z);planeBottom.scale.set(scaleXBottom,scaleYBottom,1);this.scene.add(planeBottom);parent.attach(planeBottom)}_predef_loadVideoTexture(path,loop,playbackRate){if(this.scene._amgScene==null){const video=document.createElement("video");video.src=path;video.muted=true;video.loop=loop;video.load();const videoTexture=new THREE.VideoTexture(video);videoTexture.currentTime=0;videoTexture.playbackRate=playbackRate;this.videoTexture=videoTexture;return videoTexture}else if(typeof this.scene._amgScene==="string"){return new THREE.Texture}else{const texture=new THREE.VideoTexture(path,loop,playbackRate);texture.load();return texture}}_predef_seekVideoTexture(time){if(this.videoTexture!=null){const videoTexture=this.videoTexture;const video=videoTexture.image;if(video.readyState>=2){const textureProperties=this.renderer.properties.get(videoTexture);var newTime=time/1e3*videoTexture.playbackRate;if(newTime<0){newTime=0}else if(newTime>video.duration){if(video.loop){newTime=newTime%video.duration}else{newTime=video.duration}}if(textureProperties.__version==videoTexture.version){videoTexture.currentTime=newTime;video.currentTime=videoTexture.currentTime}}}}_predef_seekShaderPass(time){if(!("shaderPasses"in this)||this.shaderPasses==null){return}this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="AnimSeqLoadAndCropBlendShaderPass"){if(this.texture1&&this.texture1.image){const ratio=this.texture1.image.width/this.texture1.image.height;if(typeof shaderPass.setAspectRatio==="function"){shaderPass.setAspectRatio(ratio)}}}})}}exports.ScriptScene=ScriptScene; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1 @@ +const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene,setCurrentScene,clearCurrentScene}=require("./wrapper/runtime");if(typeof window==="undefined"){const mockWindow={innerWidth:720,innerHeight:1280,devicePixelRatio:1,addEventListener:function(event,callback){},requestAnimationFrame:function(callback){},cancelAnimationFrame:function(id){},removeEventListener:function(event,callback){}};const mockDocument={createElement:function(tagName){return{style:{},setAttribute:function(){},appendChild:function(){}}},body:{appendChild:function(){}}};const getGlobalObject=function(){if(typeof global!=="undefined")return global;if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof this!=="undefined")return this;return{}};const globalObj=getGlobalObject();globalObj.window=mockWindow;globalObj.document=mockDocument;globalObj.cancelAnimationFrame=mockWindow.cancelAnimationFrame}const THREE={};const __THREE_CONSTS=require("./wrapper/Constants");THREE.FrontSide=__THREE_CONSTS.FrontSide;THREE.BackSide=__THREE_CONSTS.BackSide;THREE.DoubleSide=__THREE_CONSTS.DoubleSide;THREE.NoBlending=__THREE_CONSTS.NoBlending;THREE.NormalBlending=__THREE_CONSTS.NormalBlending;THREE.AdditiveBlending=__THREE_CONSTS.AdditiveBlending;THREE.SubtractiveBlending=__THREE_CONSTS.SubtractiveBlending;THREE.MultiplyBlending=__THREE_CONSTS.MultiplyBlending;THREE.CustomBlending=__THREE_CONSTS.CustomBlending;THREE.RepeatWrapping=__THREE_CONSTS.RepeatWrapping;THREE.ClampToEdgeWrapping=__THREE_CONSTS.ClampToEdgeWrapping;THREE.MirroredRepeatWrapping=__THREE_CONSTS.MirroredRepeatWrapping;const Vector2Wrapper=require("./wrapper/Vector2").Vector2;const Vector3Wrapper=require("./wrapper/Vector3").Vector3;const Vector4Wrapper=require("./wrapper/Vector4").Vector4;const EulerWrapper=require("./wrapper/Euler").Euler;const ColorWrapper=require("./wrapper/Color").Color;const Matrix4Wrapper=require("./wrapper/Matrix4").Matrix4;const QuaternionWrapper=require("./wrapper/Quaternion").Quaternion;const MathUtilsWrapper=require("./wrapper/MathUtils").MathUtils;const Box3Wrapper=require("./wrapper/Box3").Box3;const Box2Wrapper=require("./wrapper/Box2").Box2;const WebGLRendererWrapper=require("./wrapper/WebGLRenderer").WebGLRenderer;const Vector2=Vector2Wrapper;const Vector3=Vector3Wrapper;const Vector4=Vector4Wrapper;const Euler=EulerWrapper;const Color=ColorWrapper;const Matrix4=Matrix4Wrapper;const Quaternion=QuaternionWrapper;const MathUtils=MathUtilsWrapper;const Box3=Box3Wrapper;const Box2=Box2Wrapper;const WebGLRenderer=WebGLRendererWrapper;const BufferGeometryWrapper=require("./wrapper/BufferGeometry").BufferGeometry;const BufferAttributeWrapper=require("./wrapper/BufferAttribute").BufferAttribute;const BoxGeometryWrapper=require("./wrapper/BoxGeometry").BoxGeometry;const PlaneGeometryWrapper=require("./wrapper/PlaneGeometry").PlaneGeometry;const SphereGeometryWrapper=require("./wrapper/SphereGeometry").SphereGeometry;const CylinderGeometryWrapper=require("./wrapper/CylinderGeometry").CylinderGeometry;const CapsuleGeometryWrapper=require("./wrapper/CapsuleGeometry").CapsuleGeometry;const ShapeWrapper=require("./wrapper/Shape").Shape;const ShapeGeometryWrapper=require("./wrapper/ShapeGeometry").ShapeGeometry;const ExtrudeGeometryWrapper=require("./wrapper/ExtrudeGeometry").ExtrudeGeometry;const CurvePathWrapper=require("./wrapper/CurvePath").CurvePath;const LineCurveWrapper=require("./wrapper/CurvePath").LineCurve;const BufferGeometry=BufferGeometryWrapper;const BufferAttribute=BufferAttributeWrapper;const BoxGeometry=BoxGeometryWrapper;const PlaneGeometry=PlaneGeometryWrapper;const SphereGeometry=SphereGeometryWrapper;const CylinderGeometry=CylinderGeometryWrapper;const CapsuleGeometry=CapsuleGeometryWrapper;const Shape=ShapeWrapper;const ShapeGeometry=ShapeGeometryWrapper;const ExtrudeGeometry=ExtrudeGeometryWrapper;const CurvePath=CurvePathWrapper;const LineCurve=LineCurveWrapper;const TextureWrapper=require("./wrapper/Texture").Texture;const VideoTextureWrapper=require("./wrapper/Texture").VideoTexture;const TextureLoaderWrapper=require("./wrapper/Texture").TextureLoader;const Texture=TextureWrapper;const VideoTexture=VideoTextureWrapper;const TextureLoader=TextureLoaderWrapper;const MaterialWrapper=require("./wrapper/Material").Material;const MeshBasicMaterialWrapper=require("./wrapper/MeshBasicMaterial").MeshBasicMaterial;const ShaderMaterialWrapper=require("./wrapper/ShaderMaterial").ShaderMaterial;const Material=MaterialWrapper;const MeshBasicMaterial=MeshBasicMaterialWrapper;const ShaderMaterial=ShaderMaterialWrapper;const Object3DWrapper=require("./wrapper/Object3D").Object3D;const GroupWrapper=require("./wrapper/Group").Group;const MeshWrapper=require("./wrapper/Mesh").MeshWrapper;const PerspectiveCameraWrapper=require("./wrapper/PerspectiveCamera").PerspectiveCamera;const Object3D=Object3DWrapper;const Group=GroupWrapper;const Mesh=MeshWrapper;const PerspectiveCamera=PerspectiveCameraWrapper;class Scene{constructor(){this._objects=[];setCurrentScene(this);console.log("AMG scene created")}add(...objects){for(let i=0;iobj.update&&obj.update())}seekToTime(time){this._objects.forEach(obj=>obj.seekToTime&&obj.seekToTime(time))}dispose(){console.log("Scene: 开始清理场景资源");while(this._objects.length>0){const object=this._objects[0];this.delete(object);if(object.dispose&&typeof object.dispose==="function"){object.dispose()}if(object.geometry&&object.geometry.dispose){object.geometry.dispose()}if(object.material){if(Array.isArray(object.material)){object.material.forEach(material=>{if(material.dispose)material.dispose()})}else if(object.material.dispose){object.material.dispose()}}}if(this._amgScene){this._amgScene=null}this._objects=[];if(getCurrentScene()===this){clearCurrentScene()}console.log("Scene: 场景资源清理完成")}}class QuadraticBezierCurve3{constructor(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;return new Vector3(uu*this.p0.x+ut2*this.p1.x+tt*this.p2.x,uu*this.p0.y+ut2*this.p1.y+tt*this.p2.y,uu*this.p0.z+ut2*this.p1.z+tt*this.p2.z)}getPoints(divisions){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}}THREE.Vector2=Vector2;THREE.Vector3=Vector3;THREE.Vector4=Vector4;THREE.Euler=Euler;THREE.Color=Color;THREE.Matrix4=Matrix4;THREE.Quaternion=Quaternion;THREE.QuadraticBezierCurve3=QuadraticBezierCurve3;THREE.Box3=Box3;THREE.Box2=Box2;THREE.MathUtils=MathUtils;THREE.Scene=Scene;THREE.WebGLRenderer=WebGLRenderer;THREE.BufferGeometry=BufferGeometry;THREE.BufferAttribute=BufferAttribute;THREE.Float32BufferAttribute=BufferAttribute;THREE.BoxGeometry=BoxGeometry;THREE.PlaneGeometry=PlaneGeometry;THREE.SphereGeometry=SphereGeometry;THREE.CylinderGeometry=CylinderGeometry;THREE.CapsuleGeometry=CapsuleGeometry;THREE.Shape=Shape;THREE.ShapeGeometry=ShapeGeometry;THREE.ExtrudeGeometry=ExtrudeGeometry;THREE.CurvePath=CurvePath;THREE.LineCurve=LineCurve;THREE.Material=Material;THREE.MeshBasicMaterial=MeshBasicMaterial;THREE.ShaderMaterial=ShaderMaterial;THREE.Texture=Texture;THREE.VideoTexture=VideoTexture;THREE.TextureLoader=TextureLoader;THREE.Object3D=Group;THREE.Group=Group;THREE.Mesh=Mesh;THREE.PerspectiveCamera=PerspectiveCamera;exports.THREE=THREE;exports.getCurrentScene=getCurrentScene; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Easing=Object.freeze({Linear:Object.freeze({None:function(amount){return amount},In:function(amount){return amount},Out:function(amount){return amount},InOut:function(amount){return amount}}),Quadratic:Object.freeze({In:function(amount){return amount*amount},Out:function(amount){return amount*(2-amount)},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount}return-.5*(--amount*(amount-2)-1)}}),Cubic:Object.freeze({In:function(amount){return amount*amount*amount},Out:function(amount){return--amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount}return.5*((amount-=2)*amount*amount+2)}}),Quartic:Object.freeze({In:function(amount){return amount*amount*amount*amount},Out:function(amount){return 1- --amount*amount*amount*amount},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount}return-.5*((amount-=2)*amount*amount*amount-2)}}),Quintic:Object.freeze({In:function(amount){return amount*amount*amount*amount*amount},Out:function(amount){return--amount*amount*amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount*amount}return.5*((amount-=2)*amount*amount*amount*amount+2)}}),Sinusoidal:Object.freeze({In:function(amount){return 1-Math.sin((1-amount)*Math.PI/2)},Out:function(amount){return Math.sin(amount*Math.PI/2)},InOut:function(amount){return.5*(1-Math.sin(Math.PI*(.5-amount)))}}),Exponential:Object.freeze({In:function(amount){return amount===0?0:Math.pow(1024,amount-1)},Out:function(amount){return amount===1?1:1-Math.pow(2,-10*amount)},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}if((amount*=2)<1){return.5*Math.pow(1024,amount-1)}return.5*(-Math.pow(2,-10*(amount-1))+2)}}),Circular:Object.freeze({In:function(amount){return 1-Math.sqrt(1-amount*amount)},Out:function(amount){return Math.sqrt(1- --amount*amount)},InOut:function(amount){if((amount*=2)<1){return-.5*(Math.sqrt(1-amount*amount)-1)}return.5*(Math.sqrt(1-(amount-=2)*amount)+1)}}),Elastic:Object.freeze({In:function(amount){if(amount===0){return 0}if(amount===1){return 1}return-Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)},Out:function(amount){if(amount===0){return 0}if(amount===1){return 1}return Math.pow(2,-10*amount)*Math.sin((amount-.1)*5*Math.PI)+1},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}amount*=2;if(amount<1){return-.5*Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)}return.5*Math.pow(2,-10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)+1}}),Back:Object.freeze({In:function(amount){var s=1.70158;return amount===1?1:amount*amount*((s+1)*amount-s)},Out:function(amount){var s=1.70158;return amount===0?0:--amount*amount*((s+1)*amount+s)+1},InOut:function(amount){var s=1.70158*1.525;if((amount*=2)<1){return.5*(amount*amount*((s+1)*amount-s))}return.5*((amount-=2)*amount*((s+1)*amount+s)+2)}}),Bounce:Object.freeze({In:function(amount){return 1-Easing.Bounce.Out(1-amount)},Out:function(amount){if(amount<1/2.75){return 7.5625*amount*amount}else if(amount<2/2.75){return 7.5625*(amount-=1.5/2.75)*amount+.75}else if(amount<2.5/2.75){return 7.5625*(amount-=2.25/2.75)*amount+.9375}else{return 7.5625*(amount-=2.625/2.75)*amount+.984375}},InOut:function(amount){if(amount<.5){return Easing.Bounce.In(amount*2)*.5}return Easing.Bounce.Out(amount*2-1)*.5+.5}}),generatePow:function(power){if(power===void 0){power=4}power=power1e4?1e4:power;return{In:function(amount){return Math.pow(amount,power)},Out:function(amount){return 1-Math.pow(1-amount,power)},InOut:function(amount){if(amount<.5){return Math.pow(amount*2,power)/2}return(1-Math.pow(2-amount*2,power))/2+.5}}}});var now=function(){if(typeof process!=="undefined"&&process.hrtime){if(!now._nodeStartTime){now._nodeStartTime=process.hrtime()}var hrTime=process.hrtime(now._nodeStartTime);return hrTime[0]*1e3+hrTime[1]/1e6}if(typeof now._startTime==="undefined"){now._startTime=Date.now();now._lastReturned=0}var elapsed=Date.now()-now._startTime;if(elapsed<=now._lastReturned){now._lastReturned+=.001}else{now._lastReturned=elapsed}return now._lastReturned};function setNow(nowFunction){_nowFunc=nowFunction}var Group=function(){function Group(){var tweens=[];for(var _i=0;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){return fn(v[m],v[m-1],m-f)}return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0;var n=v.length-1;var pw=Math.pow;var bn=Interpolation.Utils.Bernstein;for(var i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0){i=Math.floor(f=m*(1+k))}return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0){return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0])}if(k>1){return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m])}return fn(v[i?i-1:0],v[i],v[m1;i--){s*=i}a[n]=s;return s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5;var v1=(p3-p1)*.5;var t2=t*t;var t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var Sequence=function(){function Sequence(){}Sequence.nextId=function(){return Sequence._nextId++};Sequence._nextId=0;return Sequence}();var mainGroup=new Group;var Tween=function(){function Tween(object,group){this._isPaused=false;this._pauseStart=0;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1e3;this._isDynamic=false;this._initialRepeat=0;this._repeat=0;this._yoyo=false;this._isPlaying=false;this._reversed=false;this._delayTime=0;this._startTime=0;this._easingFunction=Easing.Linear.None;this._interpolationFunction=Interpolation.Linear;this._chainedTweens=[];this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._id=Sequence.nextId();this._isChainStopped=false;this._propertiesAreSetUp=false;this._goToEnd=false;this._object=object;if(typeof group==="object"){this._group=group;group.add(this)}else if(group===true){this._group=mainGroup;mainGroup.add(this)}}Tween.prototype.getId=function(){return this._id};Tween.prototype.getCompleteCallback=function(){return this._onCompleteCallback};Tween.prototype.isPlaying=function(){return this._isPlaying};Tween.prototype.isPaused=function(){return this._isPaused};Tween.prototype.getDuration=function(){return this._duration};Tween.prototype.to=function(target,duration){if(duration===void 0){duration=1e3}if(this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");this._valuesEnd=target;this._propertiesAreSetUp=false;this._duration=duration<0?0:duration;return this};Tween.prototype.duration=function(duration){if(duration===void 0){duration=1e3}this._duration=duration<0?0:duration;return this};Tween.prototype.dynamic=function(dynamic){if(dynamic===void 0){dynamic=false}this._isDynamic=dynamic;return this};Tween.prototype.start=function(time,overrideStartingValues){if(time===void 0){time=now()}if(overrideStartingValues===void 0){overrideStartingValues=false}if(this._isPlaying){return this}this._repeat=this._initialRepeat;if(this._reversed){this._reversed=false;for(var property in this._valuesStartRepeat){this._swapEndStartRepeatValues(property);this._valuesStart[property]=this._valuesStartRepeat[property]}}this._isPlaying=true;this._isPaused=false;this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._isChainStopped=false;this._startTime=time;this._startTime+=this._delayTime;if(!this._propertiesAreSetUp||overrideStartingValues){this._propertiesAreSetUp=true;if(!this._isDynamic){var tmp={};for(var prop in this._valuesEnd)tmp[prop]=this._valuesEnd[prop];this._valuesEnd=tmp}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,overrideStartingValues)}return this};Tween.prototype.startFromCurrentValues=function(time){return this.start(time,true)};Tween.prototype._setupProperties=function(_object,_valuesStart,_valuesEnd,_valuesStartRepeat,overrideStartingValues){for(var property in _valuesEnd){var startValue=_object[property];var startValueIsArray=Array.isArray(startValue);var propType=startValueIsArray?"array":typeof startValue;var isInterpolationList=!startValueIsArray&&Array.isArray(_valuesEnd[property]);if(propType==="undefined"||propType==="function"){continue}if(isInterpolationList){var endValues=_valuesEnd[property];if(endValues.length===0){continue}var temp=[startValue];for(var i=0,l=endValues.length;itotalTime){return 1}var timesRepeated=Math.trunc(elapsedTime/durationAndDelay);var timeIntoCurrentRepeat=elapsedTime-timesRepeated*durationAndDelay;var portion=Math.min(timeIntoCurrentRepeat/_this._duration,1);if(portion===0&&elapsedTime===_this._duration){return 1}return portion};var elapsed=calculateElapsedPortion();var value=this._easingFunction(elapsed);this._updateProperties(this._object,this._valuesStart,this._valuesEnd,value);if(this._onUpdateCallback){this._onUpdateCallback(this._object,elapsed)}if(this._duration===0||elapsedTime>=this._duration){if(this._repeat>0){var completeCount=Math.min(Math.trunc((elapsedTime-this._duration)/durationAndDelay)+1,this._repeat);if(isFinite(this._repeat)){this._repeat-=completeCount}for(property in this._valuesStartRepeat){if(!this._yoyo&&typeof this._valuesEnd[property]==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(this._valuesEnd[property])}if(this._yoyo){this._swapEndStartRepeatValues(property)}this._valuesStart[property]=this._valuesStartRepeat[property]}if(this._yoyo){this._reversed=!this._reversed}this._startTime+=durationAndDelay*completeCount;if(this._onRepeatCallback){this._onRepeatCallback(this._object)}this._onEveryStartCallbackFired=false;return true}else{if(this._onCompleteCallback){this._onCompleteCallback(this._object)}for(var i=0,numChainedTweens=this._chainedTweens.length;ithis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681278636074355976/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/scriptScene.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/scriptScene.js new file mode 100644 index 0000000000000000000000000000000000000000..ebbab999b9e4c1d1e88c599b6a8b5013b25521e9 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/scriptScene.js @@ -0,0 +1,25 @@ +const TWEEN=require("./tween");const customEasings=require("./customEasings").customEasings;const THREE=require("./three-amg-wrapper").THREE;const{ShaderPass}=require("./ShaderPass.js");class ScriptScene{constructor(amgScene=null,container=null){if(amgScene){this.scene=new THREE.Scene;this.scene._amgScene=amgScene}else{this.scene=new THREE.Scene}this.effect_type="transition";this.camera=null;this.renderer=null;this.scene.background=new THREE.Color(3355443);this.isAnimating=false;this.animationFrameId=null;this.sceneObjects=null;this.texture1=null;this.texture2=null;this.composer=null;this.renderPass=null;this.usePostProcessing=true;this.initCoreObjects();if(container){this.init(container)}}destroy(){this.isAnimating=false;if(this.animationFrameId!==null&&typeof cancelAnimationFrame!=="undefined"){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}if(this.renderer){this.renderer.setAnimationLoop(null);this.renderer.dispose();if(this.renderer.domElement&&this.renderer.domElement.parentNode){this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}if(this.texture1){if(typeof this.texture1.dispose==="function")this.texture1.dispose();this.texture1=null}if(this.texture2){if(typeof this.texture2.dispose==="function")this.texture2.dispose();this.texture2=null}if(this.scene){this.scene.dispose()}if(typeof window!=="undefined"){window.removeEventListener("resize",this.handleResize)}if(this.sceneObjects&&this.sceneObjects.tweens){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.stop==="function"){tween.stop()}});this.sceneObjects.tweens=[]}if(this.shaderPasses&&this.shaderPasses.length){this.shaderPasses.forEach(pass=>{if(pass&&typeof pass.dispose==="function"){try{pass.dispose()}catch(e){}}});this.shaderPasses=[]}if(this.shaderPass&&typeof this.shaderPass.dispose==="function"){try{this.shaderPass.dispose()}catch(e){}}this.shaderPass=null;if(this.composer){this.composer.dispose();this.composer=null}this.renderPass=null;this.scene=null;this.camera=null;this.renderer=null;this.sceneObjects=null}initCoreObjects(){if(typeof window!=="undefined"){if(!window.innerWidth||!window.innerHeight){window.innerWidth=600;window.innerHeight=600}window.devicePixelRatio=window.devicePixelRatio||1;if(this.scene&&this.scene._amgScene&&this.scene._amgScene.assetMgr){const inputTexture=this.scene._amgScene.assetMgr.SyncLoad("share://input.texture");if(inputTexture&&inputTexture.width>0&&inputTexture.height>0){window.innerWidth=inputTexture.width;window.innerHeight=inputTexture.height}}}this.camera=new THREE.PerspectiveCamera(53.1,window.innerWidth/window.innerHeight,.1,1e4);this.camera.position.z=10;this.scene.add(this.camera);if(this.scene._amgScene==null){this.renderer=new THREE.WebGLRenderer({antialias:true});this.renderer.outputColorSpace=THREE.LinearSRGBColorSpace}if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight);this.renderer.setPixelRatio(window.devicePixelRatio)}this.sliders={};this.TWEEN=TWEEN;this.customEasings=customEasings;this.Duration=2e3}addShaderPass(shaderPassConfigs){if(!Array.isArray(shaderPassConfigs)){shaderPassConfigs=[shaderPassConfigs]}shaderPassConfigs.forEach(config=>{const atomicName=config.name;const className=atomicName.startsWith("Lumi")?atomicName.substring(4):atomicName;const shaderPassModule=require("../pp/Lumi"+className+"/"+className+"ShaderPass.js");const ShaderPassClass=shaderPassModule[className+"ShaderPass"];const initConfig=config&&(config.initConfig||config.config||config.params)||{};const shaderPass=new ShaderPassClass(initConfig);this.composer.addPass(shaderPass);this.shaderPasses.push(shaderPass)})}setupPostProcessing(shaderPassConfigs){const{EffectComposer}=require("./EffectComposer.js");const{RenderPass}=require("./RenderPass.js");this.composer=new EffectComposer(this.renderer);this.renderPass=new RenderPass(this.scene,this.camera);this.composer.addPass(this.renderPass);this.shaderPasses=[];this.addShaderPass(shaderPassConfigs)}initPostProcessing(){}init(container){if(this.renderer){if(container){container.appendChild(this.renderer.domElement)}else if(typeof document!=="undefined"){document.body.appendChild(this.renderer.domElement)}}if(typeof window!=="undefined"){window.addEventListener("resize",()=>this.handleResize())}}start(updateCallback){if(this.isAnimating)return;this.isAnimating=true;if(updateCallback){const animateFrame=()=>{if(!this.isAnimating)return;updateCallback();this.animationFrameId=requestAnimationFrame(animateFrame)};animateFrame()}else{this.renderer.setAnimationLoop(()=>{this.update()})}}updateScene(timestamp){if(!this.isAnimating){this.isAnimating=true}this.defaultUpdate(timestamp)}update(){if(this.usePostProcessing&&this.composer){if(this.renderPass){this.renderPass.camera=this.camera}this.composer.render()}else if(this.renderer){this.renderer.render(this.scene,this.camera)}}handleResize(){this.camera.aspect=window.innerWidth/window.innerHeight;this.camera.updateProjectionMatrix();if(this.renderer){this.renderer.setSize(window.innerWidth,window.innerHeight)}if(!this.isAnimating){this.update()}}loadTextures(){const textureLoader=new THREE.TextureLoader;return Promise.all([new Promise(resolve=>{this.texture1=textureLoader.load("image/Sample1.jpg",resolve);this.texture1.colorSpace=THREE.LinearSRGBColorSpace;this.texture1.wrapS=THREE.RepeatWrapping;this.texture1.wrapT=THREE.RepeatWrapping}),new Promise(resolve=>{this.texture2=textureLoader.load("image/Sample2.jpg",resolve);this.texture2.colorSpace=THREE.LinearSRGBColorSpace;this.texture2.wrapS=THREE.RepeatWrapping;this.texture2.wrapT=THREE.RepeatWrapping})])}_applyTweenInitialState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,0);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,0)}}_applyTweenFinalState(tween){if(!tween._propertiesAreSetUp){tween.start(0)}if(!tween._valuesStart||!tween._valuesEnd){return}tween._updateProperties(tween._object,tween._valuesStart,tween._valuesEnd,1);if(typeof tween._onUpdateCallback==="function"){tween._onUpdateCallback(tween._object,1)}}seekToTime(time){if(!this.isAnimating){this.isAnimating=true}const clampedTime=Math.max(0,Math.min(time,this.Duration));if(this._predef_seekShaderPass){this._predef_seekShaderPass(clampedTime)}if(!this.sceneObjects.tweens||this.sceneObjects.tweens.length===0){return}let notStartTweens=[];let runningTweens=[];let finishedTweens=[];for(let i=0;i<=this.sceneObjects.tweens.length-1;i++){const tween=this.sceneObjects.tweens[i];let TweenStartTime=tween._delayTime+10;let TweenEndTime=tween._delayTime+tween._duration;if(clampedTime<=TweenStartTime){notStartTweens.push({time:TweenStartTime,tween:tween})}else if(clampedTime>=TweenEndTime){finishedTweens.push({time:TweenEndTime,tween:tween})}else{runningTweens.push(tween)}}notStartTweens.sort((a,b)=>b.time-a.time);finishedTweens.sort((a,b)=>a.time-b.time);notStartTweens.forEach(item=>{this._applyTweenInitialState(item.tween)});finishedTweens.forEach(item=>{this._applyTweenFinalState(item.tween)});runningTweens.forEach(tween=>{tween.stop();tween.start(0);tween.update(clampedTime)});this.update()}setupScene(){this.initSceneObjects();this.scene.background=new THREE.Color(1710618);this.createVoxelGrid();this.setupAnimations();return this.sceneObjects}initSceneObjects(){this.Duration=2400;this.camera.position.set(0,0,10.3);this.camera.lookAt(0,0,0);this.sceneObjects={tweens:[],voxelGroup:null,voxels:[],voxelMap:{},cameraLookAt:new THREE.Vector3(0,0,0),cameraBase:new THREE.Vector3(0,0,10.3)}}createVoxelGrid(){const group=new THREE.Group;group.name="voxel_grid_2x2x1";group.position.set(0,0,0);this.scene.add(group);this.sceneObjects.voxelGroup=group;const voxelDefs=[{i:1,j:1,k:1,name:"voxel_1_1_1",pos:new THREE.Vector3(-2.5,2.5,0),row:"top"},{i:2,j:1,k:1,name:"voxel_2_1_1",pos:new THREE.Vector3(2.5,2.5,0),row:"top"},{i:1,j:2,k:1,name:"voxel_1_2_1",pos:new THREE.Vector3(-2.5,-2.5,0),row:"bottom"},{i:2,j:2,k:1,name:"voxel_2_2_1",pos:new THREE.Vector3(2.5,-2.5,0),row:"bottom"}];voxelDefs.forEach(def=>{const geometry=new THREE.BoxGeometry(5,5,.6);geometry.name=`${def.name}_geometry`;const materials=this.createVoxelFaceMaterials(def.i,def.j,def.k,def.name);const mesh=new THREE.Mesh(geometry,materials);mesh.name=def.name;mesh.position.copy(def.pos);mesh.quaternion.copy(new THREE.Quaternion);group.add(mesh);const voxelData={mesh:mesh,i:def.i,j:def.j,k:def.k,row:def.row,basePosition:def.pos.clone(),spinAxis:new THREE.Vector3(0,1,0),switched:false};this.sceneObjects.voxels.push(voxelData);this.sceneObjects.voxelMap[def.name]=voxelData})}createVoxelFaceMaterials(i,j,k,voxelName){const nx=2;const ny=2;const nz=1;const makeMat=(faceName,uvScale,uvOffset)=>{const mat=new THREE.ShaderMaterial({uniforms:{texture1:{value:this.texture1},texture2:{value:this.texture2},uvScale:{value:uvScale.clone()},uvOffset:{value:uvOffset.clone()},uUseTexture2:{value:0},u_brightness:{value:1},u_grayscale:{value:0},u_chromatic:{value:0}},vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `,fragmentShader:` + uniform sampler2D texture1; + uniform sampler2D texture2; + uniform vec2 uvScale; + uniform vec2 uvOffset; + uniform float uUseTexture2; + uniform float u_brightness; + uniform float u_grayscale; + uniform float u_chromatic; + varying vec2 vUv; + void main() { + vec2 mappedUv = uvOffset + vUv * uvScale; + vec4 colorA = texture2D(texture1, mappedUv); + vec4 colorB = texture2D(texture2, mappedUv); + vec4 texColor = mix(colorA, colorB, uUseTexture2); + texColor.rgb *= u_brightness; + gl_FragColor = texColor; + } + `,side:THREE.DoubleSide});mat.name=`${voxelName}_${faceName}_mat`;return mat};const plusXScale=new THREE.Vector2(1/nz,1/ny);const plusXOffset=new THREE.Vector2((nz-k)/nz,1-j/ny);const minusXScale=new THREE.Vector2(1/nz,1/ny);const minusXOffset=new THREE.Vector2((k-1)/nz,1-j/ny);const plusYScale=new THREE.Vector2(1/nx,1/nz);const plusYOffset=new THREE.Vector2((i-1)/nx,1-k/nz);const minusYScale=new THREE.Vector2(1/nx,1/nz);const minusYOffset=new THREE.Vector2((i-1)/nx,(k-1)/nz);const plusZScale=new THREE.Vector2(1/nx,1/ny);const plusZOffset=new THREE.Vector2((i-1)/nx,1-j/ny);const minusZScale=new THREE.Vector2(1/nx,1/ny);const minusZOffset=new THREE.Vector2((nx-i)/nx,1-j/ny);return[makeMat("px",plusXScale,plusXOffset),makeMat("nx",minusXScale,minusXOffset),makeMat("py",plusYScale,plusYOffset),makeMat("ny",minusYScale,minusYOffset),makeMat("pz",plusZScale,plusZOffset),makeMat("nz",minusZScale,minusZOffset)]}setupAnimations(){const pushTween=tween=>{tween.start();this.sceneObjects.tweens.push(tween)};const applyVoxelState=(voxelData,angle,zValue)=>{const q=(new THREE.Quaternion).setFromAxisAngle(voxelData.spinAxis,angle);voxelData.mesh.quaternion.copy(q);voxelData.mesh.position.set(voxelData.basePosition.x,voxelData.basePosition.y,zValue)};this.sceneObjects.voxels.forEach(voxelData=>{const startTime=voxelData.row==="bottom"?150:570;const spinDuration=630;const startState={angle:0,z:0};const endState={angle:Math.PI*2,z:.5};const spinTween=new TWEEN.Tween(startState).to(endState,spinDuration).delay(startTime).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{applyVoxelState(voxelData,obj.angle,obj.z)});pushTween(spinTween);const settleStart={t:0,z:.5};const settleEnd={t:1,z:0};const settleTween=new TWEEN.Tween(settleStart).to(settleEnd,1e3).delay(1200).easing(TWEEN.Easing.Quintic.Out).onUpdate(obj=>{const qStart=voxelData.mesh.quaternion.clone();const qEnd=(new THREE.Quaternion).setFromAxisAngle(voxelData.spinAxis,0);qStart.slerp(qEnd,obj.t);voxelData.mesh.quaternion.copy(qStart);voxelData.mesh.position.set(voxelData.basePosition.x,voxelData.basePosition.y,obj.z)});pushTween(settleTween)});const switchBottomStart={v:0};const switchBottomEnd={v:1};const switchBottomTween=new TWEEN.Tween(switchBottomStart).to(switchBottomEnd,50).delay(465).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{if(obj.v>0){["voxel_1_2_1","voxel_2_2_1"].forEach(name=>{const voxel=this.sceneObjects.voxelMap[name];voxel.mesh.material.forEach(m=>{m.uniforms.uUseTexture2.value=1})})}});pushTween(switchBottomTween);const switchTopStart={v:0};const switchTopEnd={v:1};const switchTopTween=new TWEEN.Tween(switchTopStart).to(switchTopEnd,50).delay(885).easing(TWEEN.Easing.Linear.None).onUpdate(obj=>{if(obj.v>0){["voxel_1_1_1","voxel_2_1_1"].forEach(name=>{const voxel=this.sceneObjects.voxelMap[name];voxel.mesh.material.forEach(m=>{m.uniforms.uUseTexture2.value=1})})}});pushTween(switchTopTween);const camUpStart={y:0,z:10.3};const camUpEnd={y:.85,z:10.9};const camUpTween=new TWEEN.Tween(camUpStart).to(camUpEnd,530).delay(150).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{this.camera.position.set(0,obj.y,obj.z);this.camera.lookAt(this.sceneObjects.cameraLookAt)});pushTween(camUpTween);const camDownStart={y:.85,z:10.9};const camDownEnd={y:.25,z:10.55};const camDownTween=new TWEEN.Tween(camDownStart).to(camDownEnd,520).delay(680).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(obj=>{this.camera.position.set(0,obj.y,obj.z);this.camera.lookAt(this.sceneObjects.cameraLookAt)});pushTween(camDownTween);const camReturnStart={y:.25,z:10.55};const camReturnEnd={y:0,z:10.3};const camReturnTween=new TWEEN.Tween(camReturnStart).to(camReturnEnd,1e3).delay(1200).easing(TWEEN.Easing.Quintic.Out).onUpdate(obj=>{this.camera.position.set(0,obj.y,obj.z);this.camera.lookAt(this.sceneObjects.cameraLookAt)});pushTween(camReturnTween)}defaultUpdate(timestamp){if(this.sceneObjects.tweens&&this.sceneObjects.tweens.length>0){this.sceneObjects.tweens.forEach(tween=>{if(tween&&typeof tween.update==="function"){tween.update(timestamp)}})}this.update()}_predef_addTopCenterBottomStyleBorder(parent,offset,texture,cutoutAreaPosition,cutoutAreaSize){const aspectRatio=this.texture1.image.width/this.texture1.image.height;const parentInitScale=parent.scale.y;const parentPosition=parent.position;const textureWidth=texture.image.width;const textureHeight=texture.image.height;const geometry=new THREE.PlaneGeometry(10,10);const textureCenter=texture.clone();textureCenter.repeat.set(1,cutoutAreaSize.y/textureHeight);textureCenter.offset.set(0,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);const materialCenter=new THREE.MeshBasicMaterial({map:textureCenter,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialCenter.name="PlaneCenterMaterial";const planeCenter=new THREE.Mesh(geometry,materialCenter);planeCenter.name="PlaneCenter";planeCenter.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y,parentPosition.z+offset.z);planeCenter.scale.set(parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth),parentInitScale,1);this.scene.add(planeCenter);parent.attach(planeCenter);const textureTop=texture.clone();textureTop.repeat.set(1,cutoutAreaPosition.y/textureHeight);textureTop.offset.set(0,1-cutoutAreaPosition.y/textureHeight);const materialTop=new THREE.MeshBasicMaterial({map:textureTop,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialTop.name="PlaneTopMaterial";const scaleXTop=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYTop=scaleXTop*cutoutAreaPosition.y/textureWidth;const planeTop=new THREE.Mesh(geometry,materialTop);planeTop.name="PlaneTop";planeTop.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y+parentInitScale*10*.5+scaleYTop*10*.5,parentPosition.z+offset.z);planeTop.scale.set(scaleXTop,scaleYTop,1);this.scene.add(planeTop);parent.attach(planeTop);const textureBottom=texture.clone();textureBottom.repeat.set(1,(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureHeight);textureBottom.offset.set(0,0);const materialBottom=new THREE.MeshBasicMaterial({map:textureBottom,transparent:true,opacity:1,premultipliedAlpha:true,side:THREE.DoubleSide});materialBottom.name="PlaneBottomMaterial";const scaleXBottom=parentInitScale*aspectRatio/(cutoutAreaSize.x/textureWidth);const scaleYBottom=scaleXBottom*(textureHeight-cutoutAreaPosition.y-cutoutAreaSize.y)/textureWidth;const planeBottom=new THREE.Mesh(geometry,materialBottom);planeBottom.name="PlaneBottom";planeBottom.position.set(parentPosition.x+offset.x,parentPosition.y+offset.y-parentInitScale*10*.5-scaleYBottom*10*.5,parentPosition.z+offset.z);planeBottom.scale.set(scaleXBottom,scaleYBottom,1);this.scene.add(planeBottom);parent.attach(planeBottom)}_predef_loadVideoTexture(path,loop,playbackRate){if(this.scene._amgScene==null){const video=document.createElement("video");video.src=path;video.muted=true;video.loop=loop;video.load();const videoTexture=new THREE.VideoTexture(video);videoTexture.currentTime=0;videoTexture.playbackRate=playbackRate;this.videoTexture=videoTexture;return videoTexture}else if(typeof this.scene._amgScene==="string"){return new THREE.Texture}else{const texture=new THREE.VideoTexture(path,loop,playbackRate);texture.load();return texture}}_predef_seekVideoTexture(time){if(this.videoTexture!=null){const videoTexture=this.videoTexture;const video=videoTexture.image;if(video.readyState>=2){const textureProperties=this.renderer.properties.get(videoTexture);var newTime=time/1e3*videoTexture.playbackRate;if(newTime<0){newTime=0}else if(newTime>video.duration){if(video.loop){newTime=newTime%video.duration}else{newTime=video.duration}}if(textureProperties.__version==videoTexture.version){videoTexture.currentTime=newTime;video.currentTime=videoTexture.currentTime}}}}_predef_seekShaderPass(time){if(!("shaderPasses"in this)||this.shaderPasses==null){return}this.shaderPasses.forEach(shaderPass=>{if(shaderPass.constructor.name==="AnimSeqLoadAndCropBlendShaderPass"){if(this.texture1&&this.texture1.image){const ratio=this.texture1.image.width/this.texture1.image.height;if(typeof shaderPass.setAspectRatio==="function"){shaderPass.setAspectRatio(ratio)}}}})}}exports.ScriptScene=ScriptScene; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/three-amg-wrapper.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/three-amg-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..c2037e314e032c4d36912923d4cc1258cba3ab19 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/three-amg-wrapper.js @@ -0,0 +1 @@ +const effect_api="undefined"!=typeof effect?effect:"undefined"!=typeof tt?tt:"undefined"!=typeof lynx?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene,setCurrentScene,clearCurrentScene}=require("./wrapper/runtime");if(typeof window==="undefined"){const mockWindow={innerWidth:720,innerHeight:1280,devicePixelRatio:1,addEventListener:function(event,callback){},requestAnimationFrame:function(callback){},cancelAnimationFrame:function(id){},removeEventListener:function(event,callback){}};const mockDocument={createElement:function(tagName){return{style:{},setAttribute:function(){},appendChild:function(){}}},body:{appendChild:function(){}}};const getGlobalObject=function(){if(typeof global!=="undefined")return global;if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof this!=="undefined")return this;return{}};const globalObj=getGlobalObject();globalObj.window=mockWindow;globalObj.document=mockDocument;globalObj.cancelAnimationFrame=mockWindow.cancelAnimationFrame}const THREE={};const __THREE_CONSTS=require("./wrapper/Constants");THREE.FrontSide=__THREE_CONSTS.FrontSide;THREE.BackSide=__THREE_CONSTS.BackSide;THREE.DoubleSide=__THREE_CONSTS.DoubleSide;THREE.NoBlending=__THREE_CONSTS.NoBlending;THREE.NormalBlending=__THREE_CONSTS.NormalBlending;THREE.AdditiveBlending=__THREE_CONSTS.AdditiveBlending;THREE.SubtractiveBlending=__THREE_CONSTS.SubtractiveBlending;THREE.MultiplyBlending=__THREE_CONSTS.MultiplyBlending;THREE.CustomBlending=__THREE_CONSTS.CustomBlending;THREE.RepeatWrapping=__THREE_CONSTS.RepeatWrapping;THREE.ClampToEdgeWrapping=__THREE_CONSTS.ClampToEdgeWrapping;THREE.MirroredRepeatWrapping=__THREE_CONSTS.MirroredRepeatWrapping;const Vector2Wrapper=require("./wrapper/Vector2").Vector2;const Vector3Wrapper=require("./wrapper/Vector3").Vector3;const Vector4Wrapper=require("./wrapper/Vector4").Vector4;const EulerWrapper=require("./wrapper/Euler").Euler;const ColorWrapper=require("./wrapper/Color").Color;const Matrix4Wrapper=require("./wrapper/Matrix4").Matrix4;const QuaternionWrapper=require("./wrapper/Quaternion").Quaternion;const MathUtilsWrapper=require("./wrapper/MathUtils").MathUtils;const Box3Wrapper=require("./wrapper/Box3").Box3;const Box2Wrapper=require("./wrapper/Box2").Box2;const WebGLRendererWrapper=require("./wrapper/WebGLRenderer").WebGLRenderer;const Vector2=Vector2Wrapper;const Vector3=Vector3Wrapper;const Vector4=Vector4Wrapper;const Euler=EulerWrapper;const Color=ColorWrapper;const Matrix4=Matrix4Wrapper;const Quaternion=QuaternionWrapper;const MathUtils=MathUtilsWrapper;const Box3=Box3Wrapper;const Box2=Box2Wrapper;const WebGLRenderer=WebGLRendererWrapper;const BufferGeometryWrapper=require("./wrapper/BufferGeometry").BufferGeometry;const BufferAttributeWrapper=require("./wrapper/BufferAttribute").BufferAttribute;const BoxGeometryWrapper=require("./wrapper/BoxGeometry").BoxGeometry;const PlaneGeometryWrapper=require("./wrapper/PlaneGeometry").PlaneGeometry;const SphereGeometryWrapper=require("./wrapper/SphereGeometry").SphereGeometry;const CylinderGeometryWrapper=require("./wrapper/CylinderGeometry").CylinderGeometry;const CapsuleGeometryWrapper=require("./wrapper/CapsuleGeometry").CapsuleGeometry;const ShapeWrapper=require("./wrapper/Shape").Shape;const ShapeGeometryWrapper=require("./wrapper/ShapeGeometry").ShapeGeometry;const ExtrudeGeometryWrapper=require("./wrapper/ExtrudeGeometry").ExtrudeGeometry;const CurvePathWrapper=require("./wrapper/CurvePath").CurvePath;const LineCurveWrapper=require("./wrapper/CurvePath").LineCurve;const BufferGeometry=BufferGeometryWrapper;const BufferAttribute=BufferAttributeWrapper;const BoxGeometry=BoxGeometryWrapper;const PlaneGeometry=PlaneGeometryWrapper;const SphereGeometry=SphereGeometryWrapper;const CylinderGeometry=CylinderGeometryWrapper;const CapsuleGeometry=CapsuleGeometryWrapper;const Shape=ShapeWrapper;const ShapeGeometry=ShapeGeometryWrapper;const ExtrudeGeometry=ExtrudeGeometryWrapper;const CurvePath=CurvePathWrapper;const LineCurve=LineCurveWrapper;const TextureWrapper=require("./wrapper/Texture").Texture;const VideoTextureWrapper=require("./wrapper/Texture").VideoTexture;const TextureLoaderWrapper=require("./wrapper/Texture").TextureLoader;const Texture=TextureWrapper;const VideoTexture=VideoTextureWrapper;const TextureLoader=TextureLoaderWrapper;const MaterialWrapper=require("./wrapper/Material").Material;const MeshBasicMaterialWrapper=require("./wrapper/MeshBasicMaterial").MeshBasicMaterial;const ShaderMaterialWrapper=require("./wrapper/ShaderMaterial").ShaderMaterial;const Material=MaterialWrapper;const MeshBasicMaterial=MeshBasicMaterialWrapper;const ShaderMaterial=ShaderMaterialWrapper;const Object3DWrapper=require("./wrapper/Object3D").Object3D;const GroupWrapper=require("./wrapper/Group").Group;const MeshWrapper=require("./wrapper/Mesh").MeshWrapper;const PerspectiveCameraWrapper=require("./wrapper/PerspectiveCamera").PerspectiveCamera;const Object3D=Object3DWrapper;const Group=GroupWrapper;const Mesh=MeshWrapper;const PerspectiveCamera=PerspectiveCameraWrapper;class Scene{constructor(){this._objects=[];setCurrentScene(this);console.log("AMG scene created")}add(...objects){for(let i=0;iobj.update&&obj.update())}seekToTime(time){this._objects.forEach(obj=>obj.seekToTime&&obj.seekToTime(time))}dispose(){console.log("Scene: 开始清理场景资源");while(this._objects.length>0){const object=this._objects[0];this.delete(object);if(object.dispose&&typeof object.dispose==="function"){object.dispose()}if(object.geometry&&object.geometry.dispose){object.geometry.dispose()}if(object.material){if(Array.isArray(object.material)){object.material.forEach(material=>{if(material.dispose)material.dispose()})}else if(object.material.dispose){object.material.dispose()}}}if(this._amgScene){this._amgScene=null}this._objects=[];if(getCurrentScene()===this){clearCurrentScene()}console.log("Scene: 场景资源清理完成")}}class QuadraticBezierCurve3{constructor(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2}getPoint(t){const u=1-t;const tt=t*t;const uu=u*u;const ut2=2*u*t;return new Vector3(uu*this.p0.x+ut2*this.p1.x+tt*this.p2.x,uu*this.p0.y+ut2*this.p1.y+tt*this.p2.y,uu*this.p0.z+ut2*this.p1.z+tt*this.p2.z)}getPoints(divisions){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}}THREE.Vector2=Vector2;THREE.Vector3=Vector3;THREE.Vector4=Vector4;THREE.Euler=Euler;THREE.Color=Color;THREE.Matrix4=Matrix4;THREE.Quaternion=Quaternion;THREE.QuadraticBezierCurve3=QuadraticBezierCurve3;THREE.Box3=Box3;THREE.Box2=Box2;THREE.MathUtils=MathUtils;THREE.Scene=Scene;THREE.WebGLRenderer=WebGLRenderer;THREE.BufferGeometry=BufferGeometry;THREE.BufferAttribute=BufferAttribute;THREE.Float32BufferAttribute=BufferAttribute;THREE.BoxGeometry=BoxGeometry;THREE.PlaneGeometry=PlaneGeometry;THREE.SphereGeometry=SphereGeometry;THREE.CylinderGeometry=CylinderGeometry;THREE.CapsuleGeometry=CapsuleGeometry;THREE.Shape=Shape;THREE.ShapeGeometry=ShapeGeometry;THREE.ExtrudeGeometry=ExtrudeGeometry;THREE.CurvePath=CurvePath;THREE.LineCurve=LineCurve;THREE.Material=Material;THREE.MeshBasicMaterial=MeshBasicMaterial;THREE.ShaderMaterial=ShaderMaterial;THREE.Texture=Texture;THREE.VideoTexture=VideoTexture;THREE.TextureLoader=TextureLoader;THREE.Object3D=Group;THREE.Group=Group;THREE.Mesh=Mesh;THREE.PerspectiveCamera=PerspectiveCamera;exports.THREE=THREE;exports.getCurrentScene=getCurrentScene; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/tween.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/tween.js new file mode 100644 index 0000000000000000000000000000000000000000..690fb9e4284728629129deed5a5a3f4bcec291ed --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/tween.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Easing=Object.freeze({Linear:Object.freeze({None:function(amount){return amount},In:function(amount){return amount},Out:function(amount){return amount},InOut:function(amount){return amount}}),Quadratic:Object.freeze({In:function(amount){return amount*amount},Out:function(amount){return amount*(2-amount)},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount}return-.5*(--amount*(amount-2)-1)}}),Cubic:Object.freeze({In:function(amount){return amount*amount*amount},Out:function(amount){return--amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount}return.5*((amount-=2)*amount*amount+2)}}),Quartic:Object.freeze({In:function(amount){return amount*amount*amount*amount},Out:function(amount){return 1- --amount*amount*amount*amount},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount}return-.5*((amount-=2)*amount*amount*amount-2)}}),Quintic:Object.freeze({In:function(amount){return amount*amount*amount*amount*amount},Out:function(amount){return--amount*amount*amount*amount*amount+1},InOut:function(amount){if((amount*=2)<1){return.5*amount*amount*amount*amount*amount}return.5*((amount-=2)*amount*amount*amount*amount+2)}}),Sinusoidal:Object.freeze({In:function(amount){return 1-Math.sin((1-amount)*Math.PI/2)},Out:function(amount){return Math.sin(amount*Math.PI/2)},InOut:function(amount){return.5*(1-Math.sin(Math.PI*(.5-amount)))}}),Exponential:Object.freeze({In:function(amount){return amount===0?0:Math.pow(1024,amount-1)},Out:function(amount){return amount===1?1:1-Math.pow(2,-10*amount)},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}if((amount*=2)<1){return.5*Math.pow(1024,amount-1)}return.5*(-Math.pow(2,-10*(amount-1))+2)}}),Circular:Object.freeze({In:function(amount){return 1-Math.sqrt(1-amount*amount)},Out:function(amount){return Math.sqrt(1- --amount*amount)},InOut:function(amount){if((amount*=2)<1){return-.5*(Math.sqrt(1-amount*amount)-1)}return.5*(Math.sqrt(1-(amount-=2)*amount)+1)}}),Elastic:Object.freeze({In:function(amount){if(amount===0){return 0}if(amount===1){return 1}return-Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)},Out:function(amount){if(amount===0){return 0}if(amount===1){return 1}return Math.pow(2,-10*amount)*Math.sin((amount-.1)*5*Math.PI)+1},InOut:function(amount){if(amount===0){return 0}if(amount===1){return 1}amount*=2;if(amount<1){return-.5*Math.pow(2,10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)}return.5*Math.pow(2,-10*(amount-1))*Math.sin((amount-1.1)*5*Math.PI)+1}}),Back:Object.freeze({In:function(amount){var s=1.70158;return amount===1?1:amount*amount*((s+1)*amount-s)},Out:function(amount){var s=1.70158;return amount===0?0:--amount*amount*((s+1)*amount+s)+1},InOut:function(amount){var s=1.70158*1.525;if((amount*=2)<1){return.5*(amount*amount*((s+1)*amount-s))}return.5*((amount-=2)*amount*((s+1)*amount+s)+2)}}),Bounce:Object.freeze({In:function(amount){return 1-Easing.Bounce.Out(1-amount)},Out:function(amount){if(amount<1/2.75){return 7.5625*amount*amount}else if(amount<2/2.75){return 7.5625*(amount-=1.5/2.75)*amount+.75}else if(amount<2.5/2.75){return 7.5625*(amount-=2.25/2.75)*amount+.9375}else{return 7.5625*(amount-=2.625/2.75)*amount+.984375}},InOut:function(amount){if(amount<.5){return Easing.Bounce.In(amount*2)*.5}return Easing.Bounce.Out(amount*2-1)*.5+.5}}),generatePow:function(power){if(power===void 0){power=4}power=power1e4?1e4:power;return{In:function(amount){return Math.pow(amount,power)},Out:function(amount){return 1-Math.pow(1-amount,power)},InOut:function(amount){if(amount<.5){return Math.pow(amount*2,power)/2}return(1-Math.pow(2-amount*2,power))/2+.5}}}});var now=function(){if(typeof process!=="undefined"&&process.hrtime){if(!now._nodeStartTime){now._nodeStartTime=process.hrtime()}var hrTime=process.hrtime(now._nodeStartTime);return hrTime[0]*1e3+hrTime[1]/1e6}if(typeof now._startTime==="undefined"){now._startTime=Date.now();now._lastReturned=0}var elapsed=Date.now()-now._startTime;if(elapsed<=now._lastReturned){now._lastReturned+=.001}else{now._lastReturned=elapsed}return now._lastReturned};function setNow(nowFunction){_nowFunc=nowFunction}var Group=function(){function Group(){var tweens=[];for(var _i=0;_i0){this._tweensAddedDuringUpdate={};for(var i=0;i1){return fn(v[m],v[m-1],m-f)}return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0;var n=v.length-1;var pw=Math.pow;var bn=Interpolation.Utils.Bernstein;for(var i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1;var f=m*k;var i=Math.floor(f);var fn=Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0){i=Math.floor(f=m*(1+k))}return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0){return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0])}if(k>1){return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m])}return fn(v[i?i-1:0],v[i],v[m1;i--){s*=i}a[n]=s;return s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5;var v1=(p3-p1)*.5;var t2=t*t;var t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var Sequence=function(){function Sequence(){}Sequence.nextId=function(){return Sequence._nextId++};Sequence._nextId=0;return Sequence}();var mainGroup=new Group;var Tween=function(){function Tween(object,group){this._isPaused=false;this._pauseStart=0;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1e3;this._isDynamic=false;this._initialRepeat=0;this._repeat=0;this._yoyo=false;this._isPlaying=false;this._reversed=false;this._delayTime=0;this._startTime=0;this._easingFunction=Easing.Linear.None;this._interpolationFunction=Interpolation.Linear;this._chainedTweens=[];this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._id=Sequence.nextId();this._isChainStopped=false;this._propertiesAreSetUp=false;this._goToEnd=false;this._object=object;if(typeof group==="object"){this._group=group;group.add(this)}else if(group===true){this._group=mainGroup;mainGroup.add(this)}}Tween.prototype.getId=function(){return this._id};Tween.prototype.getCompleteCallback=function(){return this._onCompleteCallback};Tween.prototype.isPlaying=function(){return this._isPlaying};Tween.prototype.isPaused=function(){return this._isPaused};Tween.prototype.getDuration=function(){return this._duration};Tween.prototype.to=function(target,duration){if(duration===void 0){duration=1e3}if(this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");this._valuesEnd=target;this._propertiesAreSetUp=false;this._duration=duration<0?0:duration;return this};Tween.prototype.duration=function(duration){if(duration===void 0){duration=1e3}this._duration=duration<0?0:duration;return this};Tween.prototype.dynamic=function(dynamic){if(dynamic===void 0){dynamic=false}this._isDynamic=dynamic;return this};Tween.prototype.start=function(time,overrideStartingValues){if(time===void 0){time=now()}if(overrideStartingValues===void 0){overrideStartingValues=false}if(this._isPlaying){return this}this._repeat=this._initialRepeat;if(this._reversed){this._reversed=false;for(var property in this._valuesStartRepeat){this._swapEndStartRepeatValues(property);this._valuesStart[property]=this._valuesStartRepeat[property]}}this._isPlaying=true;this._isPaused=false;this._onStartCallbackFired=false;this._onEveryStartCallbackFired=false;this._isChainStopped=false;this._startTime=time;this._startTime+=this._delayTime;if(!this._propertiesAreSetUp||overrideStartingValues){this._propertiesAreSetUp=true;if(!this._isDynamic){var tmp={};for(var prop in this._valuesEnd)tmp[prop]=this._valuesEnd[prop];this._valuesEnd=tmp}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,overrideStartingValues)}return this};Tween.prototype.startFromCurrentValues=function(time){return this.start(time,true)};Tween.prototype._setupProperties=function(_object,_valuesStart,_valuesEnd,_valuesStartRepeat,overrideStartingValues){for(var property in _valuesEnd){var startValue=_object[property];var startValueIsArray=Array.isArray(startValue);var propType=startValueIsArray?"array":typeof startValue;var isInterpolationList=!startValueIsArray&&Array.isArray(_valuesEnd[property]);if(propType==="undefined"||propType==="function"){continue}if(isInterpolationList){var endValues=_valuesEnd[property];if(endValues.length===0){continue}var temp=[startValue];for(var i=0,l=endValues.length;itotalTime){return 1}var timesRepeated=Math.trunc(elapsedTime/durationAndDelay);var timeIntoCurrentRepeat=elapsedTime-timesRepeated*durationAndDelay;var portion=Math.min(timeIntoCurrentRepeat/_this._duration,1);if(portion===0&&elapsedTime===_this._duration){return 1}return portion};var elapsed=calculateElapsedPortion();var value=this._easingFunction(elapsed);this._updateProperties(this._object,this._valuesStart,this._valuesEnd,value);if(this._onUpdateCallback){this._onUpdateCallback(this._object,elapsed)}if(this._duration===0||elapsedTime>=this._duration){if(this._repeat>0){var completeCount=Math.min(Math.trunc((elapsedTime-this._duration)/durationAndDelay)+1,this._repeat);if(isFinite(this._repeat)){this._repeat-=completeCount}for(property in this._valuesStartRepeat){if(!this._yoyo&&typeof this._valuesEnd[property]==="string"){this._valuesStartRepeat[property]=this._valuesStartRepeat[property]+parseFloat(this._valuesEnd[property])}if(this._yoyo){this._swapEndStartRepeatValues(property)}this._valuesStart[property]=this._valuesStartRepeat[property]}if(this._yoyo){this._reversed=!this._reversed}this._startTime+=durationAndDelay*completeCount;if(this._onRepeatCallback){this._onRepeatCallback(this._object)}this._onEveryStartCallbackFired=false;return true}else{if(this._onCompleteCallback){this._onCompleteCallback(this._object)}for(var i=0,numChainedTweens=this._chainedTweens.length;ithis.max.x)this.max.x=point.x;if(point.y>this.max.y)this.max.y=point.y;return this}setFromPoints(points){this.makeEmpty();for(let i=0;ithis.max.x)this.max.x=box.max.x;if(box.max.y>this.max.y)this.max.y=box.max.y;return this}intersect(box){this.min.x=Math.max(this.min.x,box.min.x);this.min.y=Math.max(this.min.y,box.min.y);this.max.x=Math.min(this.max.x,box.max.x);this.max.y=Math.min(this.max.y,box.max.y);if(this.isEmpty())this.makeEmpty();return this}translate(offset){this.min.x+=offset.x;this.min.y+=offset.y;this.max.x+=offset.x;this.max.y+=offset.y;return this}copy(box){this.min.copy(box.min);this.max.copy(box.max);return this}clone(){return(new Box2).copy(this)}containsPoint(point){return point.x>=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y}containsBox(box){return this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y)}clampPoint(point,target){if(target===undefined){target=new Vector2}target.x=Math.max(this.min.x,Math.min(this.max.x,point.x));target.y=Math.max(this.min.y,Math.min(this.max.y,point.y));return target}distanceToPoint(point){const clampedPoint=new Vector2;this.clampPoint(point,clampedPoint);return clampedPoint.distanceTo(point)}equals(box){return box.min.equals(this.min)&&box.max.equals(this.max)}}exports.Box2=Box2; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Box3.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..4100dc7442d3a622827c8a415e24557f68c491f1 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Box3.js @@ -0,0 +1 @@ +const{Vector3}=require("./Vector3");class Box3{constructor(min,max){this.min=min!==undefined?min:new Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new Vector3(-Infinity,-Infinity,-Infinity)}set(min,max){this.min.copy(min);this.max.copy(max);return this}makeEmpty(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this}isEmpty(){return this.max.x=3?array[offset+2]:0;if(xthis.max.x)this.max.x=x;if(y>this.max.y)this.max.y=y;if(z>this.max.z)this.max.z=z}return this}setFromObject(object){this.makeEmpty();return this.expandByObject(object)}expandByObject(object){object.updateWorldMatrix(false,false);const geometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null||geometry.boundingBox===undefined){geometry.computeBoundingBox()}const box=new Box3;box.copy(geometry.boundingBox);box.applyMatrix4(object.matrixWorld);this.union(box)}const children=object.children;if(children){for(let i=0;i=this.min.x&&point.x<=this.max.x&&point.y>=this.min.y&&point.y<=this.max.y&&point.z>=this.min.z&&point.z<=this.max.z}intersectsBox(box){return!(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z)}}exports.Box3=Box3; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b8b1334a62f5e88c45feee098063a199fca55 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/BoxGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class BoxGeometry extends BufferGeometry{constructor(width=1,height=1,depth=1,widthSegments=1,heightSegments=1,depthSegments=1){super();this.width=width;this.height=height;this.depth=depth;const scene=getCurrentScene();if(scene){if(widthSegments>5&&heightSegments>5&&depthSegments>5){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/BoxHighResolution.mesh")}else{this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Box.mesh").clone()}}else{console.warn("BoxGeometry: 无法加载Box.mesh,scene未创建")}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;i=this.count){console.warn(`BufferAttribute.getX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize]}getY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+1]}getZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return 0}return this.array[index*this.itemSize+2]}setX(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setX: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize]=value;this.needsUpdate=true}setY(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+1]=value;this.needsUpdate=true}setZ(index,value){if(index<0||index>=this.count){console.warn(`BufferAttribute.setZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}this.array[index*this.itemSize+2]=value;this.needsUpdate=true}setXY(index,x,y){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.needsUpdate=true}setXYZ(index,x,y,z){if(index<0||index>=this.count){console.warn(`BufferAttribute.setXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return}const offset=index*this.itemSize;this.array[offset]=x;this.array[offset+1]=y;this.array[offset+2]=z;this.needsUpdate=true}getXY(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXY: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1]}}getXYZ(index){if(index<0||index>=this.count){console.warn(`BufferAttribute.getXYZ: 索引 ${index} 超出范围 [0, ${this.count-1}]`);return{x:0,y:0,z:0}}const offset=index*this.itemSize;return{x:this.array[offset],y:this.array[offset+1],z:this.array[offset+2]}}}exports.BufferAttribute=BufferAttribute; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..af9a8a13a46500e78f082a35e18d0b5932061234 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/BufferGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferAttribute}=require("./BufferAttribute");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class BufferGeometry{constructor(){this.userData={};this.attributes={};this.index=null;this.translateValue=new Vector3(0,0,0);const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scene未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}let vertexData=this._amgObject.getVertexArray();let uvData=this._amgObject.getUvArray();let vertices=new Float32Array(vertexData.size()*3);let uvs=new Float32Array(uvData.size()*2);for(let i=0;iObject.assign({},g)):source.groups}if(source.boundingBox)this.boundingBox=source.boundingBox;if(source.boundingSphere)this.boundingSphere=source.boundingSphere;if(source.drawRange)this.drawRange=Object.assign({},source.drawRange);return this}initAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);return this}setAttribute(name,attribute){this.attributes[name]=attribute;attribute.setNameAndGeometry(name,this);attribute.forceUpdateToAMG();return this}getAttribute(name){return this.attributes[name]}computeVertexNormals(){}computeBoundingBox(){}setIndex(index){this.index=index;if(this._amgObject&&this._amgObject.submeshes.get(0)){this._amgObject.submeshes.get(0).indices16=index;this._amgObject.submeshes.get(0).indicesCount=index.length}return this}setFromPoints(points){if(!Array.isArray(points)){console.warn("setFromPoints: points must be an array");return this}const positions=[];for(let i=0;i1?r/255:r;this.g=g>1?g/255:g;this.b=b>1?b/255:b}}set(r,g,b){if(typeof r==="number"&&typeof g==="number"&&typeof b==="number"){this.r=r;this.g=g;this.b=b}else if(r instanceof Vector3){this.r=r.x;this.g=r.y;this.b=r.z}else if(r instanceof Color){this.r=r.r;this.g=r.g;this.b=r.b}else if(Array.isArray(r)&&r.length>=3){this.r=r[0];this.g=r[1];this.b=r[2]}else{console.warn("set: Unsupported color format",r,g,b)}return this}setHex(hex){hex=Math.floor(hex);this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setHexString(hexString){hexString=hexString.replace(/^#/,"");if(hexString.length===3){hexString=hexString.split("").map(char=>char+char).join("")}const hex=parseInt(hexString,16);if(isNaN(hex)){console.warn(`Invalid hex color string: ${hexString}, using white`);this.setRGB(1,1,1);return this}this.r=(hex>>16&255)/255;this.g=(hex>>8&255)/255;this.b=(hex&255)/255;return this}setRGB(r,g,b){this.r=r;this.g=g;this.b=b;return this}setHSL(h,s,l){let r,g,b;if(s===0){r=g=b=l}else{const hue2rgb=function(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p};const q=l<.5?l*(1+s):l+s-l*s;const p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}this.r=r;this.g=g;this.b=b;return this}toAMGColor(){const color=new Amaz.Vector4f;color.x=this.r;color.y=this.g;color.z=this.b;color.w=1;return color}}exports.Color=Color; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Constants.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Constants.js new file mode 100644 index 0000000000000000000000000000000000000000..6b8adda19a4d67236719804f5170889b39fd4582 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Constants.js @@ -0,0 +1 @@ +exports.FrontSide=0;exports.BackSide=1;exports.DoubleSide=2;exports.NoBlending=0;exports.NormalBlending=1;exports.AdditiveBlending=2;exports.SubtractiveBlending=3;exports.MultiplyBlending=4;exports.CustomBlending=5;exports.RepeatWrapping=1e3;exports.ClampToEdgeWrapping=1001;exports.MirroredRepeatWrapping=1002; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..29b0aad5599401be17f967ba1d48851acb70c2ac --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/CurvePath.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class CurvePath{constructor(){this.type="CurvePath";this.curves=[];this.autoClose=false;this.cacheLengths=null;this.cacheDivisions=null}add(curve){this.curves.push(curve);this.cacheLengths=null}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);const lastCurve=this.curves[this.curves.length-1];const lastPoint=lastCurve.getPoint(1);if(!lastPoint.equals(firstPoint)){this.add(new LineCurve(lastPoint,firstPoint))}}this.autoClose=true}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||points.length===0||!point.equals(points[points.length-1],epsilon)){points.push(point)}}}if(this.autoClose&&points.length>1&&!points[points.length-1].equals(points[0],epsilon)){points.push(points[0].clone())}return points}getLengths(divisions=40){if(this.cacheLengths&&this.cacheDivisions===divisions){return this.cacheLengths}const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;if(lengths.length===0)return 0;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0||this.curves.length===0){return this.curves.length>0?this.curves[0].getPoint(0):new Vector2}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}getTangent(t){const delta=1e-4;let t1=t-delta;let t2=t+delta;if(t1<0)t1=0;if(t2>1)t2=1;const pt1=this.getPoint(t1);const pt2=this.getPoint(t2);const tangent=(new Vector2).subVectors(pt2,pt1);return tangent.normalize()}getTangentAt(u){const t=this.getUtoTmapping(u);return this.getTangent(t)}getBounds(){const points=this.getPoints();let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}}class LineCurve{constructor(v1,v2){this.type="LineCurve";this.v1=v1;this.v2=v2}getPoint(t){if(t===1){return this.v2.clone()}else{const x=this.v1.x+t*(this.v2.x-this.v1.x);const y=this.v1.y+t*(this.v2.y-this.v1.y);return new Vector2(x,y)}}getPoints(divisions=1){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}getTangent(t){const tangent=(new Vector2).subVectors(this.v2,this.v1);return tangent.normalize()}getLength(){return this.v1.distanceTo(this.v2)}translate(x,y){this.v1.x+=x;this.v1.y+=y;this.v2.x+=x;this.v2.y+=y;return this}scale(x,y){this.v1.x*=x;this.v1.y*=y;this.v2.x*=x;this.v2.y*=y;return this}rotate(cos,sin){let x=this.v1.x,y=this.v1.y;this.v1.x=x*cos-y*sin;this.v1.y=x*sin+y*cos;x=this.v2.x;y=this.v2.y;this.v2.x=x*cos-y*sin;this.v2.y=x*sin+y*cos;return this}clone(){return new LineCurve(this.v1.clone(),this.v2.clone())}copy(source){this.v1.copy(source.v1);this.v2.copy(source.v2);return this}}exports.CurvePath=CurvePath;exports.LineCurve=LineCurve; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f3dee08bf1c089e040fcfef228902ab9a39c93cb --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/CylinderGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");class CylinderGeometry extends BufferGeometry{constructor(radiusTop=.5,radiusBottom=.5,height=1,radiusSegments=16,heightSegments=1){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Cylinder.mesh")}this.radiusTop=radiusTop;this.radiusBottom=radiusBottom;this.width=radiusTop/.5;this.height=height;this.depth=radiusTop/.5;this.radiusSegments=radiusSegments;this.heightSegments=heightSegments;this.scale(this.width,this.height,this.depth)}}exports.CylinderGeometry=CylinderGeometry; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Earcut.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..953abffdf38c2def26df73fed180eff8c7644ced --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Earcut.js @@ -0,0 +1 @@ +function earcut(data,holeIndices,dim){dim=dim||2;const hasHoles=holeIndices&&holeIndices.length;const outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,true);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);let minX,minY,maxX,maxY,x,y,invSize;if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(let i=dim;imaxX)maxX=x;if(y>maxY)maxY=y}invSize=Math.max(maxX-minX,maxY-minY);invSize=invSize!==0?1/invSize:0}earcutLinked(outerNode,triangles,dim,minX,minY,invSize);return triangles}function linkedList(data,start,end,dim,clockwise){let i,last;if(clockwise===signedArea(data,start,end,dim)>0){for(i=start;i=start;i-=dim)last=insertNode(i/dim,data[i],data[i+1],last)}if(last&&equals(last,last.next)){removeNode(last);last=last.next}return last}function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];let i,len,start,end,list;for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;if(x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hym.x||p.x===m.x&§orContainsSector(m,p)))){m=p;tanMin=tan}}p=p.next}while(p!==stop);return m}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;if(!pass&&invSize)indexCurve(ear,minX,minY,invSize);let stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear)){triangles.push(prev.i,ear.i,next.i);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1)}else if(pass===1){ear=cureLocalIntersections(filterPoints(ear),triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,invSize,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,invSize)}break}}}function isEar(ear){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;let p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0){return false}p=p.next}return true}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev;const b=ear;const c=ear.next;if(area(a,b,c)>=0)return false;const minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x;const maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;const minZ=zOrder(minTX,minTY,minX,minY,invSize);const maxZ=zOrder(maxTX,maxTY,minX,minY,invSize);let p=ear.prevZ;let n=ear.nextZ;while(p&&p.z>=minZ&&n&&n.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ;if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}while(n&&n.z<=maxZ){if(n!==ear.prev&&n!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,n.x,n.y)&&area(n.prev,n,n.next)>=0)return false;n=n.nextZ}return true}function cureLocalIntersections(start,triangles,dim){let p=start;do{const a=p.prev;const b=p.next.next;if(!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i,p.i,b.i);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,invSize);earcutLinked(c,triangles,dim,minX,minY,invSize);return}b=b.next}a=a.next}while(a!==start)}function indexCurve(start,minX,minY,invSize){let p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,invSize);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){let i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i0||qSize>0&&q){if(pSize!==0&&(qSize===0||!q||p.z<=q.z)){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,invSize){x=32767*(x-minX)*invSize;y=32767*(y-minY)*invSize;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){let p=start;let leftmost=start;do{if(p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2));const o2=sign(area(p1,q1,q2));const o3=sign(area(p2,q2,p1));const o4=sign(area(p2,q2,q1));if(o1!==o2&&o3!==o4)return true;if(o1===0&&onSegment(p1,p2,q1))return true;if(o2===0&&onSegment(p1,q2,q1))return true;if(o3===0&&onSegment(p2,p1,q2))return true;if(o4===0&&onSegment(p2,q1,q2))return true;return false}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(p,q){let a=p;let inside=false;const px=(p.x+q.x)/2;const py=(p.y+q.y)/2;do{const sx=a.x;const sy=a.y;const ex=a.next.x;const ey=a.next.y;if(sy>py!==ey>py&&px<(ex-sx)*(py-sy)/(ey-sy)+sx)inside=!inside;a=a.next}while(a!==p);return inside}function splitPolygon(a,b){const a2=new Node(a.i,a.x,a.y);const b2=new Node(b.i,b.x,b.y);const an=a.next;const bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){const p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}addShape(shape,shapePoints,holePoints,vertices,indices,uvs,groups,materialIndex){const vertexOffset=vertices.length/3;const groupStart=indices.length;const triangulationData=this.prepareTriangulationData(shapePoints,holePoints);if(!triangulationData)return;const{flatVertices,holeIndices,vertexCount}=triangulationData;const triangleIndices=earcut(flatVertices,holeIndices,2);if(!triangleIndices||triangleIndices.length===0){console.warn("ExtrudeGeometry: 三角化失败");return}const bounds=this.calculateBounds(flatVertices);const contour=shapePoints;const holes=holePoints||[];if(this.bevelEnabled){this.buildWithBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}else{this.buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset)}const groupCount=indices.length-groupStart;if(groupCount>0){groups.push({start:groupStart,count:groupCount,materialIndex:materialIndex})}}buildWithoutBevel(contour,holes,flatVertices,triangleIndices,bounds,vertices,indices,uvs,vertexOffset){const depth=this.depth;const steps=this.steps;const allContours=[contour].concat(holes);let currentVertexOffset=vertexOffset;for(let i=0;imaxX)maxX=contour[i].x;if(contour[i].ymaxY)maxY=contour[i].y}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const shapeWidth=maxX-minX;const shapeHeight=maxY-minY;const shapeSize=Math.max(shapeWidth,shapeHeight);const normalizedBevelSize=this.bevelSize/shapeSize;for(let layerIdx=0;layerIdx0?-dy1/len1:0;const ny1=len1>0?dx1/len1:0;const nx2=len2>0?-dy2/len2:0;const ny2=len2>0?dx2/len2:0;const nx=(nx1+nx2)/2;const ny=(ny1+ny2)/2;const nlen=Math.sqrt(nx*nx+ny*ny);normals.push({x:nlen>0?nx/nlen:0,y:nlen>0?ny/nlen:0})}return normals}prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const buffer=new effect.Amaz.FloatVector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:new Vector3(0,0,0),radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:new Vector3(centerX,centerY,centerZ),radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;this.depth=null;this.steps=null;this.bevelEnabled=null;this.bevelThickness=null;this.bevelSize=null;this.bevelOffset=null;this.bevelSegments=null;this.curveSegments=null;super.dispose()}}exports.ExtrudeGeometry=ExtrudeGeometry; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Group.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..90c4dbef65aa04d7a3bb6b6d76ec3317ea65a228 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Group.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");class Group extends Object3D{constructor(name="Group_w"){super(name)}dispose(){super.dispose()}}exports.Group=Group; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Material.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..81b97053ad9d1e4b1ef05d5ac6ed992487b2ca8e --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Material.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const __THREE_CONSTS=require("./Constants");class Material{constructor(){this.transparent=false;this._opacity=1;this.side=__THREE_CONSTS.FrontSide;this.visible=true;this.userData={};Object.defineProperty(this,"opacity",{get:()=>this._opacity,set:value=>{this._opacity=value;this._syncOpacityToAMG()},enumerable:true,configurable:true});this._blending=__THREE_CONSTS.NormalBlending;Object.defineProperty(this,"blending",{get:()=>this._blending,set:value=>{this._blending=value;this._syncBlendingToAMG()},enumerable:true,configurable:true});this._depthTest=true;this._depthWrite=true;Object.defineProperty(this,"depthTest",{get:()=>this._depthTest,set:value=>{this._depthTest=value;this._syncDepthToAMG()},enumerable:true,configurable:true});Object.defineProperty(this,"depthWrite",{get:()=>this._depthWrite,set:value=>{this._depthWrite=value;this._syncDepthToAMG()},enumerable:true,configurable:true})}_syncOpacityToAMG(){if(this._amgObject&&typeof this._amgObject.setFloat==="function"){try{this._amgObject.setFloat("u_Opacity",this._opacity);if(this._amgObject.setFloat&&typeof this._amgObject.setFloat==="function"){this._amgObject.setFloat("u_Alpha",this._opacity)}}catch(error){console.warn("Material: 同步透明度到AMG材质失败:",error)}}}_syncDepthToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const depthStencilState=this._amgObject.xshader.passes.get(0).renderState.depthstencil;depthStencilState.depthTestEnable=this._depthTest;depthStencilState.depthWriteEnable=this._depthWrite}}_applyDepthDefaults(transparent,explicitDepthTest,explicitDepthWrite){if(transparent&&this._opacity<1){this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:false}else{this._depthTest=explicitDepthTest!==undefined?explicitDepthTest:true;this._depthWrite=explicitDepthWrite!==undefined?explicitDepthWrite:true}this._syncDepthToAMG()}_syncBlendingToAMG(){if(this._amgObject!==undefined&&this._amgObject.xshader!==undefined){const colorBlendState=this._amgObject.xshader.passes.get(0).renderState.colorBlend.attachments.get(0);const setBlendState=function(state,srcColor,dstColor,srcAlpha,dstAlpha){state.srcColorBlendFactor=srcColor;state.dstColorBlendFactor=dstColor;state.srcAlphaBlendFactor=srcAlpha;state.dstAlphaBlendFactor=dstAlpha};if(this._blending==__THREE_CONSTS.NoBlending){colorBlendState.blendEnable=false;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.NormalBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.SRC_ALPHA,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA)}else if(this._blending==__THREE_CONSTS.AdditiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.SubtractiveBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE_MINUS_SRC_COLOR,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else if(this._blending==__THREE_CONSTS.MultiplyBlending){colorBlendState.blendEnable=true;setBlendState(colorBlendState,Amaz.BlendFactor.DST_COLOR,Amaz.BlendFactor.ONE_MINUS_SRC_ALPHA,Amaz.BlendFactor.ZERO,Amaz.BlendFactor.ONE)}else{Amaz.LOGE("three-amg-wrapper","混合模式未实现:"+this._blending)}}}setOpacity(opacity){this.opacity=opacity;return this}clone(){return this}dispose(){this._amgObject=null}}exports.Material=Material; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..dcf34d4cffb9de0869382a24690f78f60dda6049 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/MathUtils.js @@ -0,0 +1 @@ +const MathUtils={lerp:(a,b,t)=>a+(b-a)*t,degToRad:degrees=>degrees*Math.PI/180,radToDeg:radians=>radians*180/Math.PI,randFloat:(min,max)=>Math.random()*(max-min)+min,clamp:(value,min,max)=>Math.min(Math.max(value,min),max),euclideanModulo:(n,m)=>(n%m+m)%m,randFloatSpread:range=>Math.random()*range-range*.5};exports.MathUtils=MathUtils; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..41e6cd0a0eee7dd7bc497be5deac584806b68dc3 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Matrix4.js @@ -0,0 +1 @@ +const Vector3=require("./Vector3").Vector3;class Matrix4{constructor(){this.elements=new Float32Array(16);this.identity()}identity(){const te=this.elements;te[0]=1;te[4]=0;te[8]=0;te[12]=0;te[1]=0;te[5]=1;te[9]=0;te[13]=0;te[2]=0;te[6]=0;te[10]=1;te[14]=0;te[3]=0;te[7]=0;te[11]=0;te[15]=1;return this}fromAMGMatrix4f(m){const te=this.elements;te[0]=m.get(0,0);te[4]=m.get(0,1);te[8]=m.get(0,2);te[12]=m.get(0,3);te[1]=m.get(1,0);te[5]=m.get(1,1);te[9]=m.get(1,2);te[13]=m.get(1,3);te[2]=m.get(2,0);te[6]=m.get(2,1);te[10]=m.get(2,2);te[14]=m.get(2,3);te[3]=m.get(3,0);te[7]=m.get(3,1);te[11]=m.get(3,2);te[15]=m.get(3,3);return this}copy(m){const te=this.elements;const me=m.elements;te[0]=me[0];te[1]=me[1];te[2]=me[2];te[3]=me[3];te[4]=me[4];te[5]=me[5];te[6]=me[6];te[7]=me[7];te[8]=me[8];te[9]=me[9];te[10]=me[10];te[11]=me[11];te[12]=me[12];te[13]=me[13];te[14]=me[14];te[15]=me[15];return this}multiplyMatrices(a,b){const ae=a.elements;const be=b.elements;const te=this.elements;const a11=ae[0],a12=ae[4],a13=ae[8],a14=ae[12];const a21=ae[1],a22=ae[5],a23=ae[9],a24=ae[13];const a31=ae[2],a32=ae[6],a33=ae[10],a34=ae[14];const a41=ae[3],a42=ae[7],a43=ae[11],a44=ae[15];const b11=be[0],b12=be[4],b13=be[8],b14=be[12];const b21=be[1],b22=be[5],b23=be[9],b24=be[13];const b31=be[2],b32=be[6],b33=be[10],b34=be[14];const b41=be[3],b42=be[7],b43=be[11],b44=be[15];te[0]=a11*b11+a12*b21+a13*b31+a14*b41;te[4]=a11*b12+a12*b22+a13*b32+a14*b42;te[8]=a11*b13+a12*b23+a13*b33+a14*b43;te[12]=a11*b14+a12*b24+a13*b34+a14*b44;te[1]=a21*b11+a22*b21+a23*b31+a24*b41;te[5]=a21*b12+a22*b22+a23*b32+a24*b42;te[9]=a21*b13+a22*b23+a23*b33+a24*b43;te[13]=a21*b14+a22*b24+a23*b34+a24*b44;te[2]=a31*b11+a32*b21+a33*b31+a34*b41;te[6]=a31*b12+a32*b22+a33*b32+a34*b42;te[10]=a31*b13+a32*b23+a33*b33+a34*b43;te[14]=a31*b14+a32*b24+a33*b34+a34*b44;te[3]=a41*b11+a42*b21+a43*b31+a44*b41;te[7]=a41*b12+a42*b22+a43*b32+a44*b42;te[11]=a41*b13+a42*b23+a43*b33+a44*b43;te[15]=a41*b14+a42*b24+a43*b34+a44*b44;return this}makeRotationZ(angle){const c=Math.cos(angle);const s=Math.sin(angle);this.identity();this.elements[0]=c;this.elements[4]=-s;this.elements[1]=s;this.elements[5]=c;return this}lookAt(eye,target,up){this.identity();const z=(new Vector3).subVectors(eye,target);if(z.length()===0){z.z=1}else{z.normalize()}const x=new Vector3;up.cross(z,x);if(x.lengthSq()===0){if(Math.abs(up.z)===1){z.x+=1e-4}else{z.z+=1e-4}z.normalize();up.cross(z,x)}x.normalize();const y=(new Vector3).cross(z,x).normalize();const te=this.elements;te[0]=x.x;te[1]=x.y;te[2]=x.z;te[3]=0;te[4]=y.x;te[5]=y.y;te[6]=y.z;te[7]=0;te[8]=z.x;te[9]=z.y;te[10]=z.z;te[11]=0;te[12]=0;te[13]=0;te[14]=0;te[15]=1;return this}compose(position,quaternion,scale){const te=this.elements;const x=quaternion.x,y=quaternion.y,z=quaternion.z,w=quaternion.w;const x2=x+x,y2=y+y,z2=z+z;const xx=x*x2,xy=x*y2,xz=x*z2;const yy=y*y2,yz=y*z2,zz=z*z2;const wx=w*x2,wy=w*y2,wz=w*z2;const sx=scale.x,sy=scale.y,sz=scale.z;te[0]=(1-(yy+zz))*sx;te[1]=(xy+wz)*sx;te[2]=(xz-wy)*sx;te[3]=0;te[4]=(xy-wz)*sy;te[5]=(1-(xx+zz))*sy;te[6]=(yz+wx)*sy;te[7]=0;te[8]=(xz+wy)*sz;te[9]=(yz-wx)*sz;te[10]=(1-(xx+yy))*sz;te[11]=0;te[12]=position.x;te[13]=position.y;te[14]=position.z;te[15]=1;return this}decompose(position,quaternion,scale){position.set(0,0,0);quaternion.set(0,0,0,1);scale.set(1,1,1)}}exports.Matrix4=Matrix4; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Mesh.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..254d69b074e797dd34c16d7dad723bbcc3b4895d --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Mesh.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const{Object3D}=require("./Object3D");const{MeshBasicMaterial}=require("./MeshBasicMaterial");const{ShaderMaterial}=require("./ShaderMaterial");const{VideoTexture}=require("./Texture");class MeshWrapper extends Object3D{constructor(geometry,material){super("Mesh_w");this._amgEntity.scene=getCurrentScene()._amgScene;this._amgRenderEntity=new Amaz.Entity;this._amgRenderEntity.name="Render_w";this._amgRenderEntity.scene=getCurrentScene()._amgScene;this._amgRendertransform=this._amgRenderEntity.addComponent("Transform");this._transform.addTransform(this._amgRendertransform);this._amgRendertransform.localPosition=new effect.Amaz.Vector3f(geometry.translateValue.x||0,geometry.translateValue.y||0,geometry.translateValue.z||0);this._amgMeshRenderer=this._amgRenderEntity.addComponent("MeshRenderer");this._amgMeshRenderer.mesh=geometry._amgObject;if(material!=null){if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;imaterial,set:value=>{material=value;if(Array.isArray(material)){const materials=new effect.Amaz.Vector;for(let i=0;im.dispose&&m.dispose());else if(this.material.dispose)this.material.dispose()}}}exports.MeshWrapper=MeshWrapper; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..ac394f66efc4e113a7127ee0f50ec672e4c5e9eb --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/MeshBasicMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const Color=require("./Color").Color;const getCurrentScene=require("./runtime").getCurrentScene;class MeshBasicMaterial extends Material{constructor(parameters={}){super();this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this._color=parameters.color!==undefined?parameters.color instanceof Color?parameters.color:(new Color).setHex(parameters.color):new Color(1,1,1);this._map=null;this.wireframe=parameters.wireframe||false;this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor());if(parameters.map){this.map=parameters.map}Object.defineProperty(this,"color",{get:()=>this._color,set:value=>{this._color=value;this._amgObject.setVec4("u_AlbedoColor",this._color.toAMGColor())}});const originalSetRGB=this._color.setRGB;const material=this;this.color.setRGB=function(r,g,b){originalSetRGB.call(this,r,g,b);if(material._amgObject){material._amgObject.setVec4("u_AlbedoColor",material._color.toAMGColor())}}}get map(){return this._map}set map(value){if(this._map){this._map._removeMaterial(this)}this._map=value;if(this._map&&this._map._amgObject){this._map._addMaterial(this);this._updateMaterialParams()}}_updateMaterialParams(){if(this._map&&this._map._amgObject){this._amgObject.setTex("u_AlbedoTexture",this._map._amgObject);this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}_updateTextureParams(){if(this._map&&this._map._amgObject){this._amgObject.setVec2("u_Repeat",new effect.Amaz.Vector2f(this._map.repeat.x,this._map.repeat.y));this._amgObject.setVec2("u_Offset",new effect.Amaz.Vector2f(this._map.offset.x,this._map.offset.y))}}clone(){const clonedColor=this._color instanceof Color?new Color(this._color.r,this._color.g,this._color.b):this._color;return new MeshBasicMaterial({color:clonedColor,map:this._map?this._map.clone():null,wireframe:this.wireframe,transparent:this.transparent,opacity:this.opacity,blending:this.blending})}dispose(){if(this._map){this._map._removeMaterial(this)}super.dispose()}}exports.MeshBasicMaterial=MeshBasicMaterial; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Object3D.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..8532c6122f839460aab34fe88957802ff523318b --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Object3D.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const getCurrentScene=require("./runtime").getCurrentScene;const Vector3=require("./Vector3").Vector3;const Euler=require("./Euler").Euler;const Matrix4=require("./Matrix4").Matrix4;const Quaternion=require("./Quaternion").Quaternion;const MathUtils=require("./MathUtils").MathUtils;class Object3D{constructor(name="Object3D_w"){this._amgEntity=new Amaz.Entity;this._amgEntity.name=name;this._transform=this._amgEntity.addComponent("Transform");this.children=[];this.userData={};this.visible=true;this.isCamera=false;this.up=new Vector3(0,1,0);this.matrix=new Matrix4;this.matrixAutoUpdate=true;Object.defineProperty(this,"matrixWorld",{get:()=>{return(new Matrix4).fromAMGMatrix4f(this._transform.getWorldMatrix())},set:value=>{this._transform.worldMatrix=new effect.Amaz.Matrix4f(value.elements[0],value.elements[1],value.elements[2],value.elements[3],value.elements[4],value.elements[5],value.elements[6],value.elements[7],value.elements[8],value.elements[9],value.elements[10],value.elements[11],value.elements[12],value.elements[13],value.elements[14],value.elements[15])},enumerable:true,configurable:true});Object.defineProperty(this,"name",{get:()=>this._amgEntity.name,set:value=>{this._amgEntity.name=value}});let _visible=this.visible;Object.defineProperty(this,"visible",{get:()=>_visible,set:value=>{_visible=value;this._amgEntity.visible=value},enumerable:true,configurable:true});this.position=new Vector3;let _posX=this.position.x,_posY=this.position.y,_posZ=this.position.z;const updateTransform=()=>{if(this._transform){this._transform.localPosition=new effect.Amaz.Vector3f(_posX,_posY,_posZ)}};Object.defineProperty(this.position,"x",{get:()=>_posX,set:v=>{_posX=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"y",{get:()=>_posY,set:v=>{_posY=v;updateTransform()},enumerable:true,configurable:true});Object.defineProperty(this.position,"z",{get:()=>_posZ,set:v=>{_posZ=v;updateTransform()},enumerable:true,configurable:true});this.position.set=(x,y,z)=>{_posX=x;_posY=y;_posZ=z;updateTransform();return this.position};this.position.copy=v=>{_posX=v.x;_posY=v.y;_posZ=v.z;updateTransform();return this.position};this.position.setX=x=>{_posX=x;updateTransform();return this.position};this.position.setY=y=>{_posY=y;updateTransform();return this.position};this.position.setZ=z=>{_posZ=z;updateTransform();return this.position};this.rotation=new Euler;let _rotX=this.rotation.x,_rotY=this.rotation.y,_rotZ=this.rotation.z;let _syncing=false;const updateRotation=()=>{if(_syncing)return;_syncing=true;try{const e=new Euler(_rotX,_rotY,_rotZ,this.rotation.order);const q=(new Quaternion).setFromEuler(e);if(this._transform){this._transform.localOrientation=new effect.Amaz.Quaternionf(q.x,q.y,q.z,q.w);this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;this.quaternion.x=q.x;this.quaternion.y=q.y;this.quaternion.z=q.z;this.quaternion.w=q.w}catch(_){}_syncing=false};Object.defineProperty(this.rotation,"x",{get:()=>_rotX,set:v=>{_rotX=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"y",{get:()=>_rotY,set:v=>{_rotY=v;updateRotation()},enumerable:true,configurable:true});Object.defineProperty(this.rotation,"z",{get:()=>_rotZ,set:v=>{_rotZ=v;updateRotation()},enumerable:true,configurable:true});this.rotation.set=(x,y,z,order)=>{if(order===undefined||order===null){this.rotation.x=x;this.rotation.y=y;this.rotation.z=z;return this.rotation}this.rotation.order=order;this.quaternion=new Quaternion;for(let i=0;i{this.rotation.x=v.x;this.rotation.y=v.y;this.rotation.z=v.z;this.rotation.order=v.order;return this.rotation};this.quaternion=new Quaternion;let _qx=this.quaternion.x,_qy=this.quaternion.y,_qz=this.quaternion.z,_qw=this.quaternion.w;const updateQuaternion=()=>{if(_syncing)return;_syncing=true;try{if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(_qx,_qy,_qz,_qw);this._transform.localOrientation=amgQuat;const euler=amgQuat.quaternionToEuler();_rotX=euler.x;_rotY=euler.y;_rotZ=euler.z;this._transform.localEulerAngle=new effect.Amaz.Vector3f(_rotX/Math.PI*180,_rotY/Math.PI*180,_rotZ/Math.PI*180)}_rotX=_rotX;_rotY=_rotY;_rotZ=_rotZ}catch(_){}_syncing=false};Object.defineProperty(this.quaternion,"x",{get:()=>_qx,set:v=>{_qx=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"y",{get:()=>_qy,set:v=>{_qy=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"z",{get:()=>_qz,set:v=>{_qz=v;updateQuaternion()},enumerable:true,configurable:true});Object.defineProperty(this.quaternion,"w",{get:()=>_qw,set:v=>{_qw=v;updateQuaternion()},enumerable:true,configurable:true});this.quaternion.set=function(x,y,z,w){_qx=x;_qy=y;_qz=z;_qw=w;updateQuaternion();return this};this.quaternion.copy=function(q){_qx=q.x;_qy=q.y;_qz=q.z;_qw=q.w;updateQuaternion();return this};const originalSetFromAxisAngle=this.quaternion.setFromAxisAngle.bind(this.quaternion);this.quaternion.setFromAxisAngle=function(axis,angle){const r=originalSetFromAxisAngle(axis,angle);_qx=this.x;_qy=this.y;_qz=this.z;_qw=this.w;updateQuaternion();return r};this.scale=new Vector3(1,1,1);let _sx=this.scale.x,_sy=this.scale.y,_sz=this.scale.z;const updateScale=()=>{if(this._transform)this._transform.localScale=new effect.Amaz.Vector3f(_sx,_sy,_sz)};Object.defineProperty(this.scale,"x",{get:()=>_sx,set:v=>{_sx=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"y",{get:()=>_sy,set:v=>{_sy=v;updateScale()},enumerable:true,configurable:true});Object.defineProperty(this.scale,"z",{get:()=>_sz,set:v=>{_sz=v;updateScale()},enumerable:true,configurable:true});this.scale.set=(x,y,z)=>{_sx=x;_sy=y;_sz=z;updateScale();return this.scale};this.scale.setScalar=v=>{_sx=v;_sy=v;_sz=v;updateScale()};this.scale.setX=x=>{_sx=x;updateScale();return this.scale};this.scale.setY=y=>{_sy=y;updateScale();return this.scale};this.scale.setZ=z=>{_sz=z;updateScale();return this.scale};this.scale.copy=v=>{_sx=v.x;_sy=v.y;_sz=v.z;updateScale();return this.scale}}clone(recursive=true){const cloned=new Object3D(this.name+"_clone");cloned.visible=this.visible;cloned.isCamera=this.isCamera;cloned.up.copy(this.up);cloned.userData={...this.userData};cloned.position.copy(this.position);cloned.rotation.copy(this.rotation);cloned.quaternion.copy(this.quaternion);cloned.scale.copy(this.scale);if(recursive){for(const child of this.children){const clonedChild=child.clone(recursive);cloned.add(clonedChild)}}return cloned}traverse(callback){callback(this);if(this.children&&this.children.length>0){this.children.forEach(child=>{if(child.traverse)child.traverse(callback);else callback(child)})}}getWorldPosition(target){if(!target)target=new Vector3;if(this._transform&&this._transform.worldPosition){target.set(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z)}else{target.copy(this.position)}return target}getWorldQuaternion(target){if(!target)target=new Quaternion;if(this._transform&&this._transform.worldOrientation)target.fromAMGQuaternion(this._transform.worldOrientation);else target.copy(this.quaternion);return target}add(object){if(object===this){console.warn("Object3D.add: 不能将对象添加到自身");return this}if(object.parent!==undefined){object.parent.remove(object)}object.parent=this;this.children.push(object);if(object._transform)this._transform.addTransform(object._transform);return this}remove(object){const index=this.children.indexOf(object);if(index!==-1){object.parent=undefined;this.children.splice(index,1);const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(object._amgEntity)}return this}attach(child){if(!child||!child._transform){console.warn("attach error: invalid child or missing _transform component");return}this.children.push(child);this._transform.addTransform(child._transform);child._transform.worldPosition=child._transform.localPosition;child._transform.worldRotation=child._transform.localRotation;child._transform.worldScale=child._transform.localScale;return this}rotateX(angle){this.rotation.x+=angle;return this}rotateY(angle){this.rotation.y+=angle;return this}rotateZ(angle){this.rotation.z+=angle;return this}rotateOnAxis(vec3,rad){const axis=vec3.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,rad);const currentQuat=this.quaternion.clone();currentQuat.multiply(q);this.quaternion.set(currentQuat.x,currentQuat.y,currentQuat.z,currentQuat.w);if(this._transform){const amgQuat=new effect.Amaz.Quaternionf(this.quaternion.x,this.quaternion.y,this.quaternion.z,this.quaternion.w);const euler=amgQuat.quaternionToEuler();this.rotation.set(euler.x,euler.y,euler.z)}return this}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(flag){}lookAt(x,y,z){if(x instanceof Vector3){this.lookAt(x.x,x.y,x.z);return this}const pos=new Vector3(this._transform.worldPosition.x,this._transform.worldPosition.y,this._transform.worldPosition.z);const tarOri=new Vector3(x,y,z);const Tar3=new Vector3(2*pos.x-tarOri.x,2*pos.y-tarOri.y,2*pos.z-tarOri.z);if(!this.isCamera){Tar3.copy(tarOri)}const normal=Tar3.clone().normalize();const angle=new Vector3(0-normal.x,1-normal.y,0-normal.z);if(angle.length()<.001)return this;const tar=new effect.Amaz.Vector3f(Tar3.x,Tar3.y,Tar3.z);const up=new effect.Amaz.Vector3f(0,1,0);this._transform.lookAt(tar,up);this.quaternion.set(this._transform.localOrientation.x,this._transform.localOrientation.y,this._transform.localOrientation.z,this._transform.localOrientation.w);return this}worldToLocal(worldPos){const localPos=new Vector3;if(!this._transform||!worldPos)return localPos;const thisWorldPos=this._transform.worldPosition;localPos.set(worldPos.x-thisWorldPos.x,worldPos.y-thisWorldPos.y,worldPos.z-thisWorldPos.z);try{if(this._transform.worldOrientation){const worldQ=(new Quaternion).fromAMGQuaternion(this._transform.worldOrientation).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}else if(this._transform.worldRotation){const ex=this._transform.worldRotation.x/180*Math.PI;const ey=this._transform.worldRotation.y/180*Math.PI;const ez=this._transform.worldRotation.z/180*Math.PI;const worldEuler=new Euler(ex,ey,ez);const worldQ=(new Quaternion).setFromEuler(worldEuler).normalize();const invQ=new Quaternion(-worldQ.x,-worldQ.y,-worldQ.z,worldQ.w).normalize();localPos.applyQuaternion(invQ)}}catch(_){}if(this._transform.worldScale){const ws=this._transform.worldScale;const sx=ws.x||1,sy=ws.y||1,sz=ws.z||1;if(sx!==0)localPos.x/=sx;if(sy!==0)localPos.y/=sy;if(sz!==0)localPos.z/=sz}return localPos}updateWorldMatrix(force=false,updateParents=false){}dispose(){while(this.children.length>0){const child=this.children[0];this.remove(child);if(child.dispose&&typeof child.dispose==="function")child.dispose()}const currentScene=getCurrentScene();if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null;this.children=[]}}exports.Object3D=Object3D; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..ba39801de50d38ec04424f3c2ebfa2ff5d28fded --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/PerspectiveCamera.js @@ -0,0 +1 @@ +const{Object3D}=require("./Object3D");const{getCurrentScene}=require("./runtime");class PerspectiveCamera extends Object3D{constructor(fov=75,aspect=1,near=.1,far=1e3){super("PerspectiveCamera_w");this._amgEntity.scene=getCurrentScene()._amgScene;this.isCamera=true;this._amgObject=this._amgEntity.addComponent("Camera");this._amgObject.type=effect.Amaz.CameraType.PERSPECTIVE;this._amgObject.clearType=effect.Amaz.CameraClearType.COLOR_DEPTH;this._amgObject.clearColor=new effect.Amaz.Color(0,0,0,0);this._amgObject.layerVisibleMask=new effect.Amaz.DynamicBitset(1,1);this._amgObject.renderOrder=0;const renderTexture=getCurrentScene()._amgScene.assetMgr.SyncLoad("rt/RT_0.rt");this._amgObject.renderTexture=renderTexture;this._fov=fov;this.fovy=fov;this.aspect=aspect;this.near=near;this.far=far;this.updateProjectionMatrix()}set fov(value){this._fov=value;this.fovy=value;this.updateProjectionMatrix()}updateProjectionMatrix(){this._amgObject.fovy=this.fovy;this._amgObject.aspect=this.aspect;this._amgObject.zNear=this.near;this._amgObject.zFar=this.far}update(){}dispose(){const currentScene=getCurrentScene();if(this._amgEntity){if(currentScene&¤tScene._amgScene)currentScene._amgScene.removeEntity(this._amgEntity);if(this._amgObject.renderTexture){this._amgObject.renderTexture=null}if(this._amgObject){this._amgEntity.removeComponent(this._amgObject);this._amgObject=null}if(this._transform){this._amgEntity.removeComponent(this._transform);this._transform=null}this._amgEntity=null}}}exports.PerspectiveCamera=PerspectiveCamera; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bc595fb80ad9e7c2f4d8360c67dbef556f3d6cbe --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/PlaneGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class PlaneGeometry extends BufferGeometry{constructor(width=1,height=1,widthSegments=1,heightSegments=1){super();this.width=width;this.height=height;this.widthSegments=widthSegments;this.heightSegments=heightSegments;const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Quad.mesh").clone()}else{console.warn("PlaneGeometry: 无法加载Quad.mesh,scerne未创建")}{var vertexAttribs=this._amgObject.vertexAttribs;var attribDesc0=new effect.Amaz.VertexAttribDesc;attribDesc0.semantic=effect.Amaz.VertexAttribType.POSITION_OFFSET;attribDesc0.bindingIndex=0;attribDesc0.offset=36;attribDesc0.componentCount=3;vertexAttribs.pushBack(attribDesc0);var attribDesc1=new effect.Amaz.VertexAttribDesc;attribDesc1.semantic=effect.Amaz.VertexAttribType.TEXCOORD1;attribDesc1.bindingIndex=0;attribDesc1.offset=48;attribDesc1.componentCount=2;vertexAttribs.pushBack(attribDesc1);this._amgObject.vertexAttribs=vertexAttribs;const submesh=this._amgObject.submeshes.get(0);if(submesh){submesh.primitive=effect.Amaz.Primitive.TRIANGLES}}const gridX=widthSegments;const gridY=heightSegments;const gridX1=gridX+1;const gridY1=gridY+1;const segmentWidth=width/gridX;const segmentHeight=height/gridY;const vertices=[];const uvs=[];const indices=[];for(let iy=0;iy0){const invLen=1/len;this.x*=invLen;this.y*=invLen;this.z*=invLen;this.w*=invLen}return this}identity(){this.x=0;this.y=0;this.z=0;this.w=1;return this}multiply(q){const x=this.x,y=this.y,z=this.z,w=this.w;const qx=q.x,qy=q.y,qz=q.z,qw=q.w;this.x=w*qx+x*qw+y*qz-z*qy;this.y=w*qy-x*qz+y*qw+z*qx;this.z=w*qz+x*qy-y*qx+z*qw;this.w=w*qw-x*qx-y*qy-z*qz;return this}setFromAxisAngle(axis,angle){const halfAngle=angle/2;const s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this}setFromEuler(euler){const x=euler.x/2;const y=euler.y/2;const z=euler.z/2;const cx=Math.cos(x);const sx=Math.sin(x);const cy=Math.cos(y);const sy=Math.sin(y);const cz=Math.cos(z);const sz=Math.sin(z);this.x=sx*cy*cz+cx*sy*sz;this.y=cx*sy*cz-sx*cy*sz;this.z=cx*cy*sz+sx*sy*cz;this.w=cx*cy*cz-sx*sy*sz;return this}slerp(q,t){const dot=this.x*q.x+this.y*q.y+this.z*q.z+this.w*q.w;let qx=q.x,qy=q.y,qz=q.z,qw=q.w;let dotValue=dot;if(dot<0){qx=-qx;qy=-qy;qz=-qz;qw=-qw;dotValue=-dotValue}const dotClamped=Math.max(-1,Math.min(1,dotValue));const theta=Math.acos(dotClamped);if(theta<.001){this.x=this.x+(qx-this.x)*t;this.y=this.y+(qy-this.y)*t;this.z=this.z+(qz-this.z)*t;this.w=this.w+(qw-this.w)*t}else{const sinTheta=Math.sin(theta);const sinThetaT=Math.sin(theta*t);const sinTheta1T=Math.sin(theta*(1-t));this.x=(this.x*sinTheta1T+qx*sinThetaT)/sinTheta;this.y=(this.y*sinTheta1T+qy*sinThetaT)/sinTheta;this.z=(this.z*sinTheta1T+qz*sinThetaT)/sinTheta;this.w=(this.w*sinTheta1T+qw*sinThetaT)/sinTheta}this.normalize();return this}setFromRotationMatrix(matrix){const te=matrix.elements;const m11=te[0],m12=te[4],m13=te[8];const m21=te[1],m22=te[5],m23=te[9];const m31=te[2],m32=te[6],m33=te[10];const trace=m11+m22+m33;let s;if(trace>0){s=Math.sqrt(trace+1)*2;this.w=.25*s;this.x=(m32-m23)/s;this.y=(m13-m31)/s;this.z=(m21-m12)/s}else if(m11>m22&&m11>m33){s=Math.sqrt(1+m11-m22-m33)*2;this.w=(m32-m23)/s;this.x=.25*s;this.y=(m12+m21)/s;this.z=(m13+m31)/s}else if(m22>m33){s=Math.sqrt(1+m22-m11-m33)*2;this.w=(m13-m31)/s;this.x=(m12+m21)/s;this.y=.25*s;this.z=(m23+m32)/s}else{s=Math.sqrt(1+m33-m11-m22)*2;this.w=(m21-m12)/s;this.x=(m13+m31)/s;this.y=(m23+m32)/s;this.z=.25*s}this.normalize();if(this.w<0){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w}return this}slerpQuaternions(q1,q2,t){this.copy(q1);return this.slerp(q2,t)}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`Quaternion(${this.x}, ${this.y}, ${this.z}, ${this.w})`}toAMGQuaternion(){return new effect.Amaz.Quaternionf(this.x,this.y,this.z,this.w)}fromAMGQuaternion(q){this.x=q.x;this.y=q.y;this.z=q.z;this.w=q.w;return this}}exports.Quaternion=Quaternion; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..02dc1be955bc766de744222a7e75c65bf147bb61 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/ShaderMaterial.js @@ -0,0 +1 @@ +const Material=require("./Material").Material;const __THREE_CONSTS=require("./Constants");const getCurrentScene=require("./runtime").getCurrentScene;const Vector2=require("./Vector2").Vector2;const Vector3=require("./Vector3").Vector3;const Vector4=require("./Vector4").Vector4;const Color=require("./Color").Color;const Texture=require("./Texture").Texture;const ARRAY_PROXY_FLAG=Symbol("ShaderMaterialArrayProxy");const MUTATING_ARRAY_METHODS=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin","copy","set"]);const __uniformBindingMap=new WeakMap;function __registerUniformBinding(uniform,material,key){let list=__uniformBindingMap.get(uniform);if(!list){list=[];__uniformBindingMap.set(uniform,list)}if(!list.some(b=>b.material===material&&b.key===key)){list.push({material:material,key:key})}}function __notifyUniformBindings(uniform,value){const list=__uniformBindingMap.get(uniform);if(!list)return;for(const b of list){if(b&&b.material&&typeof b.material._syncUniformToAMG==="function"){b.material._syncUniformToAMG(b.key,value)}}}class ShaderMaterial extends Material{constructor(parameters={}){super();this.originalVertexShader=parameters.vertexShader;this.originalFragmentShader=parameters.fragmentShader;this.scene=getCurrentScene();this._amgObject=this.scene._amgScene.assetMgr.SyncLoad("material/Unlit/Unlit.material").clone();this.transparent=parameters.transparent||false;this.opacity=parameters.opacity!==undefined?parameters.opacity:1;this._applyDepthDefaults(this.transparent,parameters.depthTest,parameters.depthWrite);if(this.transparent==true){this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NormalBlending}else{this.blending=parameters.blending!==undefined?parameters.blending:__THREE_CONSTS.NoBlending}this._originalUniforms=parameters.uniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);if(parameters.uniforms){for(const[key,value]of Object.entries(parameters.uniforms)){this._syncUniformToAMG(key,value.value)}}let key="";if(parameters.vertexShader&¶meters.fragmentShader){let vertLength=parameters.vertexShader.length;let fragLength=parameters.fragmentShader.length;if(vertLength>0&&fragLength>0){key="c_"+vertLength+"_"+fragLength}}let xshader=this._amgObject.xshader.clone();let passes=xshader.passes;let pass=passes.get(0);let shaders=pass.shaders;let gles2=shaders.get("gles2");let glesShader1=gles2.get(0);let glesShader2=gles2.get(1);if(parameters.vertexShader){let shader=parameters.vertexShader;shader=shader.replace(/\buv\b/g,"attTexcoord0");shader=shader.replace(/\bnormal\b/g,"attNormal");shader=shader.replace(/\bposition\b/g,"attPosition");shader=shader.replace(/\bnormalMatrix\b/g,"mat3(u_MV)");shader=shader.replace(/\bmodelMatrix\b/g,"u_Model");shader=shader.replace(/\bviewMatrix\b/g,"u_View");shader=shader.replace(/\bmodelViewMatrix\b/g,"u_MV");shader=shader.replace(/\bprojectionMatrix\b/g,"u_Projection");shader=shader.replace(/\bmodelViewProjectionMatrix\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_View \* u_Model\b/g,"u_MVP");shader=shader.replace(/\bu_Projection \* u_MV\b/g,"u_MVP");parameters.vertexShader="precision highp float; attribute vec3 attPosition; attribute vec2 attTexcoord0; attribute vec3 attNormal; uniform mat4 u_MVP; uniform mat4 u_MV; uniform mat4 u_Projection; uniform mat4 u_Model; uniform mat4 u_View; "+shader;glesShader1.source=parameters.vertexShader;glesShader1.sourcePath=""}if(parameters.fragmentShader){parameters.fragmentShader="precision highp float;"+parameters.fragmentShader;glesShader2.source=parameters.fragmentShader;glesShader2.sourcePath=""}var rootDir=this.scene._amgScene.assetMgr.rootDir;var vertMetalPath=rootDir+"xshader/"+key+".vert.metal";var fragMetalPath=rootDir+"xshader/"+key+".frag.metal";var metalFileExist=false;var swingTemplateUtils=null;if(effect.Amaz.SwingTemplateUtils){swingTemplateUtils=new effect.Amaz.SwingTemplateUtils}if(swingTemplateUtils&&swingTemplateUtils.isFileExist(vertMetalPath)&&swingTemplateUtils.isFileExist(fragMetalPath)){metalFileExist=true}if(metalFileExist==false){let metal=shaders.get("metal");if(metal){shaders.remove("metal")}}else{let metal=shaders.get("metal");let metalShader1=metal.get(0);let metalShader2=metal.get(1);metalShader1.source="";metalShader1.sourcePath="xshader/"+key+".vert.metal";metalShader2.source="";metalShader2.sourcePath="xshader/"+key+".frag.metal"}this._amgObject.xshader=xshader}_createUniformsProxy(originalUniforms){const uniformsProxy={};for(const[key,uniform]of Object.entries(originalUniforms)){uniformsProxy[key]={get value(){return uniform.value},set value(newValue){uniform.value=newValue}}}return uniformsProxy}_cloneUniforms(sourceUniforms){if(!sourceUniforms)return{};const cloned={};for(const[key,uniform]of Object.entries(sourceUniforms)){if(!uniform||typeof uniform!=="object")continue;cloned[key]={value:this._cloneUniformValue(uniform.value)}}return cloned}_cloneUniformValue(value){if(value instanceof Texture){return value}if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return typeof value.clone==="function"?value.clone():value}if(value instanceof Color){return new Color(value.r,value.g,value.b)}if(Array.isArray(value)){return value.map(v=>this._cloneUniformValue(v))}if(value&&typeof value==="object"){return{...value}}return value}_hookUniforms(originalUniforms){if(!originalUniforms)return;for(const[key,uniform]of Object.entries(originalUniforms)){this._hookSingleUniform(key,uniform)}}_hookSingleUniform(key,uniform){if(!uniform||typeof uniform!=="object")return;this._normalizeUniformValue(uniform);__registerUniformBinding(uniform,this,key);this._attachUniformVectorObserver(uniform);this._attachUniformArrayObserver(uniform,key);if(uniform._amgUniformHooked)return;try{let _val=uniform.value;Object.defineProperty(uniform,"value",{get:()=>_val,set:v=>{_val=this._convertUniformValue(v);this._attachUniformVectorObserver(uniform,_val);const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}__notifyUniformBindings(uniform,_val)},enumerable:true,configurable:true});const proxied=this._attachUniformArrayObserver(uniform,key,_val);if(proxied){_val=proxied}Object.defineProperty(uniform,"_amgUniformHooked",{value:true,enumerable:false,configurable:true})}catch(e){}}_looksLikeVector(obj,components){if(!obj||typeof obj!=="object")return false;return components.every(c=>typeof obj[c]==="number")}_normalizeUniformValue(uniform){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const converted=this._convertUniformValue(uniform.value);if(converted===uniform.value)return;const descriptor=Object.getOwnPropertyDescriptor(uniform,"value");if(descriptor&&typeof descriptor.set==="function"&&typeof descriptor.get==="function"){descriptor.set.call(uniform,converted)}else{uniform.value=converted}}_convertUniformValue(value){if(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4){return value}if(value instanceof Color){return new Vector3(value.r,value.g,value.b)}if(Array.isArray(value)){const nums=value;if(nums.length===2&&nums.every(v=>typeof v==="number")){return new Vector2(nums[0],nums[1])}else if(nums.length===3&&nums.every(v=>typeof v==="number")){return new Vector3(nums[0],nums[1],nums[2])}else if(nums.length===4&&nums.every(v=>typeof v==="number")){return new Vector4(nums[0],nums[1],nums[2],nums[3])}return value}if(this._looksLikeVector(value,["x","y","z","w"])){return new Vector4(value.x,value.y,value.z,value.w)}else if(this._looksLikeVector(value,["x","y","z"])){return new Vector3(value.x,value.y,value.z)}else if(this._looksLikeVector(value,["x","y"])){return new Vector2(value.x,value.y)}return value}_attachUniformVectorObserver(uniform,valueOverride){if(!uniform||typeof uniform!=="object"||!("value"in uniform))return;const value=valueOverride||uniform.value;if(!(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4||value instanceof Color)){return}if(value.__amgUniformVectorHooked)return;const wrapMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);__notifyUniformBindings(uniform,value);return result}};wrapMethod("set");wrapMethod("copy");if(value instanceof Color){wrapMethod("setRGB");wrapMethod("setHex");wrapMethod("setHexString");wrapMethod("setHSL")}Object.defineProperty(value,"__amgUniformVectorHooked",{value:true,enumerable:false,configurable:true})}_attachUniformArrayObserver(uniform,key,valueOverride){if(!uniform||typeof uniform!=="object")return null;const value=valueOverride||uniform.value;const isTyped=this._isTypedArray(value);if(!Array.isArray(value)&&!isTyped)return null;if(value&&value[ARRAY_PROXY_FLAG])return value;const notifyArrayChange=()=>{try{__notifyUniformBindings(uniform,proxy)}catch(e){try{this._syncUniformToAMG(key,{value:proxy})}catch(err){}}};const proxy=this._getArrayProxy(value,notifyArrayChange);if(Array.isArray(value)){for(let i=0;i{if(typeof element[methodName]!=="function")return;const original=element[methodName].bind(element);element[methodName]=(...args)=>{const result=original(...args);notifyArrayChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(element,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}}}return proxy}_getArrayProxy(arrayTarget,onChange){if(!this._arrayProxyMap){this._arrayProxyMap=new WeakMap}if(this._arrayProxyMap.has(arrayTarget)){return this._arrayProxyMap.get(arrayTarget)}const notifyChange=()=>{try{onChange()}catch(e){}};const handler={get(target,prop,receiver){const value=Reflect.get(target,prop,receiver);if(typeof value==="function"&&MUTATING_ARRAY_METHODS.has(prop)){return function(){const result=value.apply(target,arguments);notifyChange();return result}}if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}return value},set(target,prop,value,receiver){const result=Reflect.set(target,prop,value,receiver);if(typeof prop==="string"&&/^\d+$/.test(prop)&&(value instanceof Vector2||value instanceof Vector3||value instanceof Vector4)){if(!value.__amgArrayElementHooked){const wrapElementMethod=methodName=>{if(typeof value[methodName]!=="function")return;const original=value[methodName].bind(value);value[methodName]=(...args)=>{const result=original(...args);notifyChange();return result}};wrapElementMethod("set");wrapElementMethod("copy");Object.defineProperty(value,"__amgArrayElementHooked",{value:true,enumerable:false,configurable:true})}}notifyChange();return result}};const proxy=new Proxy(arrayTarget,handler);Object.defineProperty(proxy,ARRAY_PROXY_FLAG,{value:true,enumerable:false,configurable:false});this._arrayProxyMap.set(arrayTarget,proxy);return proxy}_isTypedArray(value){return typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(value)}_resolveUniformValueAndType(key,valueOrObject){let resolvedValue=valueOrObject;let resolvedType=undefined;if(valueOrObject&&typeof valueOrObject==="object"&&valueOrObject!==null&&"value"in valueOrObject){resolvedValue=valueOrObject.value;resolvedType=valueOrObject.type}if(!resolvedType&&this._originalUniforms&&this._originalUniforms[key]&&typeof this._originalUniforms[key]==="object"){resolvedType=this._originalUniforms[key].type}return{value:resolvedValue,type:resolvedType}}_syncUniformToAMG(key,valueOrObject){if(!this._amgObject)return;const{value,type}=this._resolveUniformValueAndType(key,valueOrObject);if(value===undefined||value===null)return;const convertedValue=Array.isArray(value)||this._isTypedArray(value)?value:this._convertUniformValue(value);let yModified=undefined;if(convertedValue instanceof Vector2||convertedValue instanceof Vector3){if(key==="videoTextureRepeat")yModified=-convertedValue.y;else if(key==="videoTextureOffset")yModified=-convertedValue.y+1;else yModified=convertedValue.y}const toVec2=(x,y)=>new effect.Amaz.Vector2f(x,y);const toVec3=(x,y,z)=>new effect.Amaz.Vector3f(x,y,z);const toVec4=(x,y,z,w)=>new effect.Amaz.Vector4f(x,y,z,w);const numbersOnly=arr=>Array.isArray(arr)&&arr.every(item=>typeof item==="number");try{if(convertedValue instanceof Texture){this._amgObject.setTex(key,convertedValue._amgObject);return}if(convertedValue instanceof Vector2){const y=typeof yModified==="number"?yModified:convertedValue.y;this._amgObject.setVec2(key,toVec2(convertedValue.x,y));return}if(convertedValue instanceof Vector3){this._amgObject.setVec3(key,toVec3(convertedValue.x,convertedValue.y,convertedValue.z));return}if(convertedValue instanceof Vector4){this._amgObject.setVec4(key,toVec4(convertedValue.x,convertedValue.y,convertedValue.z,convertedValue.w));return}if(typeof convertedValue==="number"){if(type&&type==="i"){this._amgObject.setInt(key,convertedValue)}else{this._amgObject.setFloat(key,convertedValue)}return}if(typeof convertedValue==="boolean"){this._amgObject.setFloat(key,convertedValue?1:0);return}if(Array.isArray(convertedValue)||this._isTypedArray(convertedValue)){let arr=Array.isArray(convertedValue)?convertedValue.slice():Array.from(convertedValue);if(Array.isArray(arr[0])){arr=arr.flat()}const allNums=numbersOnly(arr);if(!type||type==="vec2"||type==="vec3"||type==="vec4"){if(arr.length===2&&allNums&&(!type||type==="vec2")){this._amgObject.setVec2(key,toVec2(arr[0],arr[1]));return}if(arr.length===3&&allNums&&(!type||type==="vec3")){this._amgObject.setVec3(key,toVec3(arr[0],arr[1],arr[2]));return}if(arr.length===4&&allNums&&(!type||type==="vec4")){this._amgObject.setVec4(key,toVec4(arr[0],arr[1],arr[2],arr[3]));return}}const setVec2Array=list=>{const vecs=new effect.Amaz.Vec2Vector;if(numbersOnly(list)){if(list.length%2!==0){console.warn(`Expected vec2[] for ${key}, got length ${list.length}`)}for(let i=0;i=2){vecs.pushBack(toVec2(item[0],item[1]))}}}this._amgObject.setVec2Vector(key,vecs)};const setVec3Array=list=>{const vecs=new effect.Amaz.Vec3Vector;if(numbersOnly(list)){if(list.length%3!==0){console.warn(`Expected vec3[] for ${key}, got length ${list.length}`)}for(let i=0;i=3){vecs.pushBack(toVec3(item[0],item[1],item[2]))}}}this._amgObject.setVec3Vector(key,vecs)};const setVec4Array=list=>{const vecs=new effect.Amaz.Vec4Vector;if(numbersOnly(list)){if(list.length%4!==0){console.warn(`Expected vec4[] for ${key}, got length ${list.length}`)}for(let i=0;i=4){vecs.pushBack(toVec4(item[0],item[1],item[2],item[3]))}}}this._amgObject.setVec4Vector(key,vecs)};const setFloatArray=list=>{const floats=new effect.Amaz.FloatVector;for(const num of list){if(typeof num==="number"){floats.pushBack(num)}}this._amgObject.setFloatVector(key,floats)};if(type==="vec2[]"){setVec2Array(arr);return}if(type==="vec3[]"){setVec3Array(arr);return}if(type==="vec4[]"){setVec4Array(arr);return}if(type==="float[]"){setFloatArray(arr);return}console.warn(`Unsupported array uniform type for ${key}:`,type||typeof convertedValue);return}console.warn(`Unsupported uniform type for ${key}:`,convertedValue)}catch(error){console.error(`Failed to sync uniform ${key} to AMG:`,error)}}get uniforms(){return this._uniforms}set uniforms(newUniforms){this._originalUniforms=newUniforms||{};this._uniforms=this._createUniformsProxy(this._originalUniforms);this._hookUniforms(this._originalUniforms);for(const[key,uniform]of Object.entries(this._originalUniforms)){if(uniform&&"value"in uniform){this._syncUniformToAMG(key,uniform.value)}}}clone(){const clonedUniforms=this._cloneUniforms(this._originalUniforms);return new ShaderMaterial({uniforms:clonedUniforms,vertexShader:this.originalVertexShader,fragmentShader:this.originalFragmentShader,transparent:this.transparent,blending:this.blending,depthTest:this.depthTest,depthWrite:this.depthWrite,opacity:this.opacity})}dispose(){this._amgObject=null;this._originalUniforms=null;this._uniforms=null;this._arrayProxyMap=null;this._originalVertexShader=null;this._originalFragmentShader=null;this.scene=null}}exports.ShaderMaterial=ShaderMaterial; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Shape.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..ecde48b5ceb30812c922aa5c7cfe2aa7b50cabe4 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Shape.js @@ -0,0 +1 @@ +const{Vector2}=require("./Vector2");class Shape{constructor(points){this.type="Shape";this.uuid=generateUUID();this.currentPoint=new Vector2;this.curves=[];this.holes=[];if(points!==undefined){this.moveTo(points[0].x,points[0].y);for(let i=1;i0){const firstPoint=curve.getPoint(0);if(!firstPoint.equals(this.currentPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}this.curves.push(curve);const lastPoint=curve.getPoint(1);this.currentPoint.copy(lastPoint);return this}closePath(){if(this.curves.length>0){const firstPoint=this.curves[0].getPoint(0);if(!this.currentPoint.equals(firstPoint)){this.lineTo(firstPoint.x,firstPoint.y)}}return this}getPoints(divisions=12){const points=[];const epsilon=1e-10;for(let i=0;i0||(points.length===0||!point.equals(points[points.length-1],epsilon))){points.push(point)}}}return points}extractPoints(divisions){return{shape:this.getPoints(divisions),holes:this.holes.map(hole=>hole.getPoints(divisions))}}translate(x,y){for(let i=0;imaxX)maxX=p.x;if(p.ymaxY)maxY=p.y}return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}getLengths(divisions=40){if(!this.cacheLengths||this.cacheDivisions!==divisions){const lengths=[];let sum=0;for(let i=0;i0?lengths[lengths.length-1]:0}getPointAt(u){const t=this.getUtoTmapping(u);return this.getPoint(t)}getUtoTmapping(u){const divisions=this.cacheDivisions||40;const lengths=this.getLengths(divisions);if(u===0)return 0;if(u===1)return 1;const targetLength=u*lengths[lengths.length-1];let low=0;let high=lengths.length-1;let comparison;while(low<=high){const i=Math.floor(low+(high-low)/2);comparison=lengths[i]-targetLength;if(comparison<0){low=i+1}else if(comparison>0){high=i-1}else{high=i;break}}let i=high;if(i<0)i=0;if(i>=lengths.length)i=lengths.length-1;const lengthBefore=i>0?lengths[i-1]:0;const lengthAfter=lengths[i];const segmentLength=lengthAfter-lengthBefore;const segmentFraction=segmentLength===0?0:(targetLength-lengthBefore)/segmentLength;const t=(i+segmentFraction)/(this.curves.length*divisions);return t}getPoint(t){const divisions=this.cacheDivisions||40;const d=t*this.curves.length*divisions;const segmentIndex=Math.floor(d);const segmentT=d-segmentIndex;const curveIndex=Math.floor(segmentIndex/divisions);const divisionIndex=segmentIndex%divisions;const curveT=(divisionIndex+segmentT)/divisions;if(curveIndex<0){return this.curves[0].getPoint(0)}if(curveIndex>=this.curves.length){return this.curves[this.curves.length-1].getPoint(1)}return this.curves[curveIndex].getPoint(curveT)}getSpacedPoints(divisions=5){const points=[];if(this.curves.length===0){return points}for(let i=0;i<=divisions;i++){points.push(this.getPointAt(i/divisions))}return points}dispose(){if(this.curves){for(let i=0;ipoints.length-2?points.length-1:intPoint+1];const p3=points[intPoint>points.length-3?points.length-1:intPoint+2];const x=catmullRom(weight,p0.x,p1.x,p2.x,p3.x);const y=catmullRom(weight,p0.y,p1.y,p2.y,p3.y);return new Vector2(x,y)}getPoints(divisions=12){const points=[];for(let i=0;i<=divisions;i++){points.push(this.getPoint(i/divisions))}return points}translate(x,y){for(let i=0;itwoPi)deltaAngle-=twoPi;if(deltaAngle>4;uuid[i]=chars[i===19?r&3|8:r]}}return uuid.join("")}exports.Shape=Shape; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3786abc7d64ed80b56101c4ac9d30ce9fcb8f941 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/ShapeGeometry.js @@ -0,0 +1 @@ +const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");const{earcut}=require("./Earcut");const{Vector2}=require("./Vector2");const{Vector3}=require("./Vector3");const{Box3}=require("./Box3");class ShapeGeometry extends BufferGeometry{constructor(shapes,curveSegments=12){super();this.type="ShapeGeometry";this.parameters={shapes:shapes,curveSegments:curveSegments};const shapesArray=Array.isArray(shapes)?shapes:[shapes];const vertices=[];const indices=[];const uvs=[];const groups=[];let groupStart=0;let groupCount=0;for(let i=0;i0){const bounds=calculateBounds(flatVertices);const vertexOffset=vertices.length/3;for(let j=0;j0){this.setAttribute("position",new BufferAttribute(new Float32Array(vertices),3));this.setAttribute("uv",new BufferAttribute(new Float32Array(uvs),2));if(indices.length>0){this.setIndex(indices)}this.updateAMGObject(vertices,indices,uvs)}this.groups=groups}updateAMGObject(vertices,indices,uvs){if(!this._amgObject||!this._amgObject.submeshes)return;try{const submesh=this._amgObject.submeshes.get(0);if(!submesh)return;submesh.primitive=effect.Amaz.Primitive.TRIANGLES;const vertexCount=vertices.length/3;const vertexArray=new effect.Amaz.Vec3Vector;for(let i=0;i0){const indexArray=new effect.Amaz.UInt16Vector;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}this.boundingBox=new Box3(new Vector3(minX,minY,minZ),new Vector3(maxX,maxY,maxZ))}computeBoundingSphere(){const positionAttribute=this.attributes.position;if(!positionAttribute){this.boundingSphere={center:{x:0,y:0,z:0},radius:0};return}const positions=positionAttribute.array;let minX=Infinity,minY=Infinity,minZ=Infinity;let maxX=-Infinity,maxY=-Infinity,maxZ=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y;if(zmaxZ)maxZ=z}const centerX=(minX+maxX)/2;const centerY=(minY+maxY)/2;const centerZ=(minZ+maxZ)/2;let maxRadiusSq=0;for(let i=0;imaxRadiusSq)maxRadiusSq=distSq}this.boundingSphere={center:{x:centerX,y:centerY,z:centerZ},radius:Math.sqrt(maxRadiusSq)}}dispose(){if(this.groups){this.groups.length=0;this.groups=null}this.parameters=null;super.dispose()}}function prepareTriangulationData(shapePoints,holePoints){if(!shapePoints||shapePoints.length<3){console.warn("ShapeGeometry: 形状点数量不足");return null}const flatVertices=[];const holeIndices=[];for(let i=0;i0){for(let i=0;i0){holeIndices.push(vertexCount);for(let j=0;j0?holeIndices:null,vertexCount:vertexCount}}function calculateBounds(vertices){let minX=Infinity,minY=Infinity;let maxX=-Infinity,maxY=-Infinity;for(let i=0;imaxX)maxX=x;if(ymaxY)maxY=y}if(maxX===minX)maxX=minX+1;if(maxY===minY)maxY=minY+1;return{minX:minX,minY:minY,maxX:maxX,maxY:maxY}}exports.ShapeGeometry=ShapeGeometry; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..1ea27a55fbce9fc3771c66840c068e5ff6347092 --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/SphereGeometry.js @@ -0,0 +1 @@ +const{getCurrentScene}=require("./runtime");const{BufferGeometry}=require("./BufferGeometry");const{BufferAttribute}=require("./BufferAttribute");class SphereGeometry extends BufferGeometry{constructor(radius=1,widthSegments=8,heightSegments=6){super();const scene=getCurrentScene();if(scene){this._amgObject=scene._amgScene.assetMgr.SyncLoad("mesh/Sphere.mesh")}this.width=radius;this.height=radius;this.depth=radius;const vertexCount=(widthSegments+1)*(heightSegments+1);const vertices=new Float32Array(vertexCount*3);const uvs=new Float32Array(vertexCount*2);this.initAttribute("position",new BufferAttribute(vertices,3));this.initAttribute("uv",new BufferAttribute(uvs,2));this.scale(this.width,this.height,this.depth)}}exports.SphereGeometry=SphereGeometry; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Texture.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..35bff49d732c9884e07bfcb5682f18a860485e1f --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Texture.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;const{getCurrentScene}=require("./runtime");const Vector2=require("./Vector2").Vector2;const __THREE_CONSTS=require("./Constants");class Texture{constructor(){this._amgObject=null;this._materials=[];this.repeat=new Vector2(1,1);this.offset=new Vector2(0,0);this.center=new Vector2(.5,.5);this.rotation=0;this._setupListeners();this._wrapS=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapS",{get:()=>this._wrapS,set:value=>{this._wrapS=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeS=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true});this._wrapT=__THREE_CONSTS.ClampToEdgeWrapping;Object.defineProperty(this,"wrapT",{get:()=>this._wrapT,set:value=>{this._wrapT=value;if(this._amgObject!==undefined){if(value==__THREE_CONSTS.RepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.REPEAT}else if(value==__THREE_CONSTS.ClampToEdgeWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.CLAMP}else if(value==__THREE_CONSTS.MirroredRepeatWrapping){this._amgObject.wrapModeT=Amaz.WrapMode.Mirror}}},enumerable:true,configurable:true})}setImage(image){this._amgObject=image;this.image=image;this.wrapS=this._wrapS;this.wrapT=this._wrapT}clone(){const cloned=new Texture;cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}dispose(){this._amgObject=null;this.image=null;this._materials=[]}_addMaterial(material){if(!this._materials.includes(material))this._materials.push(material)}_removeMaterial(material){const i=this._materials.indexOf(material);if(i>-1)this._materials.splice(i,1)}_setupListeners(){this.repeat=new Proxy(this.repeat,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});this.offset=new Proxy(this.offset,{set:(target,property,value)=>{target[property]=value;this._notifyMaterials();return true}});const originalRepeatSet=this.repeat.set.bind(this.repeat);this.repeat.set=(x,y)=>{const r=originalRepeatSet(x,y);this._notifyMaterials();return r};const originalOffsetSet=this.offset.set.bind(this.offset);this.offset.set=(x,y)=>{const r=originalOffsetSet(x,y);this._notifyMaterials();return r}}_notifyMaterials(){this._materials.forEach(m=>{if(m._updateTextureParams)m._updateTextureParams()})}}class VideoTexture extends Texture{constructor(path,loop,playbackRate){super();this.path=path;this.loop=loop;this.playbackRate=playbackRate}clone(){const cloned=new VideoTexture(this.path,this.loop,this.playbackRate);cloned._amgObject=this._amgObject;cloned.repeat.set(this.repeat.x,this.repeat.y);cloned.offset.set(this.offset.x,this.offset.y);return cloned}load(){const amgScene=getCurrentScene()._amgScene;this._amgEntity=new Amaz.Entity;this._amgEntity.name="VideoTextureEntity";this._amgEntity.scene=amgScene;this._transform=this._amgEntity.addComponent("Transform");this._amgVideoAnimSeq=this._amgEntity.addComponent("VideoAnimSeq");this._amgVideoAnimSeq.videoFilename=this.path;this._amgVideoAnimSeq.texName="_MainTex";this._amgVideoAnimSeq.playmode=this.loop?Amaz.PlayMode.loop:Amaz.PlayMode.once;this._amgVideoAnimSeq.speed=this.playbackRate;this._amgVideoAnimSeq.autoplay=true;this._amgVideoAnimSeq.enableAlphaBlend=false;this._amgVideoAnimSeq.enableFixedSeekMode=true;this._amgSprite2DRenderer=this._amgEntity.addComponent("Sprite2DRenderer");this._amgSprite2DRenderer.enabled=false;amgScene.addEntity(this._amgEntity)}dispose(){this._amgEntity=null;this._amgVideoAnimSeq=null;this._amgSprite2DRenderer=null}}class TextureLoader{constructor(){}load(url,onLoad,onProgress,onError){const texture=new Texture;const assetMgr=getCurrentScene()._amgScene.assetMgr;texture.setImage(assetMgr.SyncLoad(url));if(onLoad!==undefined)onLoad(texture);return texture}}exports.Texture=Texture;exports.VideoTexture=VideoTexture;exports.TextureLoader=TextureLoader; \ No newline at end of file diff --git a/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Vector2.js b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..a30a2431264ee62cec937714dfa9e50932ddedeb --- /dev/null +++ b/scripts/7681299452761525520/AmazingFeature/js/ThreeJS/wrapper/Vector2.js @@ -0,0 +1 @@ +const effect_api=typeof effect!=="undefined"?effect:typeof tt!=="undefined"?tt:typeof lynx!=="undefined"?lynx:{};const Amaz=effect_api.getAmaz?effect_api.getAmaz():null;class Vector2{constructor(x=0,y=0){this.x=x;this.y=y}set(x,y){this.x=x;this.y=y;return this}toAMGVector2(){return new Amaz.Vector2f(this.x,this.y)}copy(v){this.x=v.x;this.y=v.y;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;return this}clone(){return new Vector2(this.x,this.y)}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const length=this.length();if(length>0){this.x/=length;this.y/=length}return this}subScalar(s){this.x-=s;this.y-=s;return this}addScalar(s){this.x+=s;this.y+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;return this}divideScalar(s){this.x/=s;this.y/=s;return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;return Math.sqrt(dx*dx+dy*dy)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z}cross(v,target){const ax=this.x,ay=this.y,az=this.z;const bx=v.x,by=v.y,bz=v.z;if(target){target.x=ay*bz-az*by;target.y=az*bx-ax*bz;target.z=ax*by-ay*bx;return target}else{this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this}}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;return this}lerp(v,t){this.x=this.x+(v.x-this.x)*t;this.y=this.y+(v.y-this.y)*t;this.z=this.z+(v.z-this.z)*t;return this}lerpVectors(vec1,vec2,t){this.x=vec1.x+(vec2.x-vec1.x)*t;this.y=vec1.y+(vec2.y-vec1.y)*t;this.z=vec1.z+(vec2.z-vec1.z)*t;return this}applyQuaternion(quat){const qx=quat.x;const qy=quat.y;const qz=quat.z;const qw=quat.w;const vx=this.x;const vy=this.y;const vz=this.z;const x=(qw*qw+qx*qx-qy*qy-qz*qz)*vx+2*(qx*qy-qw*qz)*vy+2*(qx*qz+qw*qy)*vz;const y=2*(qx*qy+qw*qz)*vx+(qw*qw-qx*qx+qy*qy-qz*qz)*vy+2*(qy*qz-qw*qx)*vz;const z=2*(qx*qz-qw*qy)*vx+2*(qy*qz+qw*qx)*vy+(qw*qw-qx*qx-qy*qy+qz*qz)*vz;this.x=x;this.y=y;this.z=z;return this}applyMatrix4(matrix){const e=matrix.elements;const x=this.x,y=this.y,z=this.z;const w=e[3]*x+e[7]*y+e[11]*z+e[15];this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];if(w!==1&&w!==0){this.x/=w;this.y/=w;this.z/=w}return this}applyAxisAngle(vector,angle){const axis=vector.clone().normalize();const q=(new Quaternion).setFromAxisAngle(axis,angle);this.applyQuaternion(q);return this}applyEuler(euler){const q=(new Quaternion).setFromEuler(euler);this.applyQuaternion(q);return this}addVectors(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this}subVectors(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;return this}toAMGVector3(){return new Amaz.Vector3f(this.x,this.y,this.z)}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;return this}min(v){this.x=Math.min(this.x,v.x);this.y=Math.min(this.y,v.y);this.z=Math.min(this.z,v.z);return this}max(v){this.x=Math.max(this.x,v.x);this.y=Math.max(this.y,v.y);this.z=Math.max(this.z,v.z);return this}distanceTo(v){const dx=this.x-v.x;const dy=this.y-v.y;const dz=this.z-v.z;return Math.sqrt(dx*dx+dy*dy+dz*dz)}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x)0){this.x/=length;this.y/=length;this.z/=length;this.w/=length}return this}multiplyScalar(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;this.w*=scalar;return this}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}dot(v){return this.x*v.x+this.y*v.y+this.z*v.z+this.w*v.w}sub(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}copy(v){this.x=v.x;this.y=v.y;this.z=v.z;this.w=v.w;return this}subScalar(s){this.x-=s;this.y-=s;this.z-=s;this.w-=s;return this}addScalar(s){this.x+=s;this.y+=s;this.z+=s;this.w+=s;return this}multiplyScalar(s){this.x*=s;this.y*=s;this.z*=s;this.w*=s;return this}divideScalar(s){this.x/=s;this.y/=s;this.z/=s;this.w/=s;return this}equals(v,epsilon=Number.EPSILON){return Math.abs(this.x-v.x){if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-6*k)*Math.cos(12*k)};const springStiff=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(18*k)};const dampedOscillation=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.exp(-5*k)*Math.cos(10*k)};const Physics=Object.freeze({SpringSoft:springSoft,SpringStiff:springStiff,DampedOscillation:dampedOscillation});const anticipate=k=>{if(k<=0)return 0;if(k>=1)return 1;const pullback=.1;if(k<.3){const p=k/.3;return-pullback*p*(2-p)}const p=(k-.3)/.7;return-pullback+(1+pullback)*p*p*(3-2*p)};const overshootFactory=peak=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return peak*p*(2-p)}const p=(k-.6)/.4;return peak+(1-peak)*(1-Math.pow(1-p,3))};const overshoot110=overshootFactory(1.1);const overshoot125=overshootFactory(1.25);const snapBack=k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.6){const p=k/.6;return 1.05*(1-Math.pow(1-p,3))}const p=(k-.6)/.4;return 1.05-.05*p*p*(3-2*p)};const swing=k=>{if(k<=0)return 0;if(k>=1)return 1;return 1-Math.cos(1.5*Math.PI*k)*Math.exp(-2.5*k)};const Motion=Object.freeze({Anticipate:anticipate,Overshoot110:overshoot110,Overshoot125:overshoot125,SnapBack:snapBack,Swing:swing});const makeStep=(n,jumpTerm="end")=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(jumpTerm==="start")return Math.ceil(k*n)/n;return Math.floor(k*n)/n};const Step=Object.freeze({Steps4End:makeStep(4,"end"),Steps8End:makeStep(8,"end"),Steps12End:makeStep(12,"end")});function buildCubicBezier(x1,y1,x2,y2){const cx=3*x1,bx=3*(x2-x1)-cx,ax=1-cx-bx;const cy=3*y1,by=3*(y2-y1)-cy,ay=1-cy-by;const sampleX=s=>((ax*s+bx)*s+cx)*s;const sampleY=s=>((ay*s+by)*s+cy)*s;const sampleDX=s=>(3*ax*s+2*bx)*s+cx;const solveS=x=>{let s=x;for(let i=0;i<8;i++){const cur=sampleX(s)-x;if(Math.abs(cur)<1e-6)return s;const d=sampleDX(s);if(Math.abs(d)<1e-6)break;s-=cur/d;if(s<0)s=0;if(s>1)s=1}let lo=0,hi=1;for(let i=0;i<32&&hi-lo>1e-6;i++){const mid=(lo+hi)/2;if(sampleX(mid){if(k<=0)return 0;if(k>=1)return 1;return sampleY(solveS(k))}}const BEZIER_PRESETS=Object.freeze({"Material.Standard":[.4,0,.2,1],"Material.Accelerate":[.4,0,1,1],"Material.Decelerate":[0,0,.2,1],"CSS.Ease":[.25,.1,.25,1]});const _bezierCache=new Map;function _cachedBezier(x1,y1,x2,y2){const key=x1+","+y1+","+x2+","+y2;let fn=_bezierCache.get(key);if(!fn){fn=buildCubicBezier(x1,y1,x2,y2);_bezierCache.set(key,fn)}return fn}function cubicBezier(a,b,c,d){if(typeof a==="string"){let preset=BEZIER_PRESETS[a];if(!preset){console.warn("[customEasings.cubicBezier] unknown preset, falling back to Material.Standard:",a);preset=BEZIER_PRESETS["Material.Standard"]}return _cachedBezier(preset[0],preset[1],preset[2],preset[3])}const clamp=(v,lo,hi)=>Math.max(lo,Math.min(hi,v));const x1=clamp(a,0,1);const y1=clamp(b,-.5,1.5);const x2=clamp(c,0,1);const y2=clamp(d,-.5,1.5);return _cachedBezier(x1,y1,x2,y2)}const libSpring=({stiffness=180,damping=12,mass=1}={})=>{const DT=1/240;const T=1.5;let x=0,v=0;const samples=[];for(let t=0;t<=T;t+=DT){const force=-stiffness*(x-1)-damping*v;v+=force/mass*DT;x+=v*DT;samples.push({t:t,x:x})}let T_end=T;for(let i=samples.length-1;i>=0;i--){if(Math.abs(samples[i].x-1)>.01){T_end=samples[i].t;break}}return k=>{if(k<=0)return 0;if(k>=1)return 1;const t=k*T_end;const idx=Math.min(samples.length-1,Math.floor(t/DT));return samples[idx].x}};const libHeartBeat=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c)=>Math.exp(-((t-c)**2)/(2*.07*.07));return peak*(bell(k,.2)+bell(k,.5))};const libSteps=(n=6)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return Math.floor(k*n)/n};const attentionPing=(peak=.35,decay=2)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(Math.PI*k)*Math.exp(-decay*k)};const attentionWiggle=(count=4,amplitude=.25)=>k=>{if(k<=0||k>=1)return 0;const env=1-k;return amplitude*env*Math.sin(k*Math.PI*2*count)};const attentionStrum=(notes=4,peak=.4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*.05*.05))}return peak*sum}};const Attention=Object.freeze({Ping:attentionPing(),Wiggle:attentionWiggle(),Strum:attentionStrum()});const breathNormal=(cycles=2,peak=.15)=>k=>{if(k<=0||k>=1)return 0;return peak*Math.sin(k*Math.PI*2*cycles)*Math.sin(k*Math.PI)};const breathDeep=(peak=.3,riseRatio=.35,holdRatio=.15)=>{const holdEnd=riseRatio+holdRatio;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const envelope=Math.sin(k*Math.PI);const wave=.5+.5*Math.sin(k*Math.PI*2*cycles-Math.PI/2);return peak*envelope*wave};const breathSigh=(peak=.25,riseRatio=.2)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return peak*Math.exp(-((k-center)**2)/(2*width*width))};const heartExcited=(beats=4,peak=.3,width=.04)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*width*width))}return peak*sum}};const heartLubDub=(peak=.3)=>k=>{if(k<=0||k>=1)return 0;const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return peak*(bell(k,.25,.045)+.6*bell(k,.42,.03))};const Heart=Object.freeze({Calm:heartCalm(),Excited:heartExcited(),LubDub:heartLubDub()});const mathJumpArc=()=>k=>{if(k<=0||k>=1)return 0;return 4*k*(1-k)};const mathPendulum=(damping=3,freq=2.5)=>k=>{if(k<=0||k>=1)return 0;return Math.sin(k*Math.PI)*Math.exp(-damping*k)*Math.cos(freq*Math.PI*k)};const mathTremor=(amplitude=.04,freq=22)=>k=>{if(k<=0)return 0;if(k>=1)return 1;return k+amplitude*Math.sin(k*Math.PI*2*freq)};const mathBoomerang=fn=>k=>{if(k<=0||k>=1)return 0;return k<.5?fn(k*2):fn(2-k*2)};const MathExt=Object.freeze({JumpArc:mathJumpArc(),Pendulum:mathPendulum(),Tremor:mathTremor()});const explosionImpulse=(sharpness=6)=>{const tail=sharpness*Math.exp(1-sharpness);return k=>{if(k<=0||k>=1)return 0;const h=sharpness*k;return h*Math.exp(1-h)-tail*k}};const explosionFlash=(rise=.05,decay=5)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;return-Math.exp(-decay*k)*Math.cos(freq*Math.PI*k)};const explosionImplosion=(charge=.3,depth=.4,burstPeak=1.2)=>{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const w=Math.sin(k*Math.PI*2*cycles)+.5*Math.sin(k*Math.PI*2*cycles*1.5+1.2)+.25*Math.sin(k*Math.PI*2*cycles*3+2.4);return amplitude*env*w*.6};const natureFlicker=(rate=15,intensity=.2,seed=7)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=rate+1;i++)samples.push(rand());return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*rate;const idx=Math.floor(pos);const t=pos-idx;const a=samples[idx];const b=samples[idx+1];const interp=a+(b-a)*t;return intensity*env*(interp-.5)*2}};const natureGust=(gusts=3,peak=.25)=>{const centers=[];const span=.7;for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const c of centers){sum+=Math.exp(-((k-c)**2)/(2*.08*.08))}return peak*sum/gusts*1.8}};const Nature=Object.freeze({Wave:natureWave(),Flicker:natureFlicker(),Gust:natureGust()});const impactRain=(impactAt=.7,rippleAmp=.08)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const liftEnd=.35,strikeEnd=.6;return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return t*t}const t=(k-.4)/.6;const env=Math.exp(-2.5*t);const wave=Math.abs(Math.sin(t*Math.PI*bounces));return 1-env*wave*rebound};const impactSlap=(contactAt=.3,holdRatio=.1)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k{const sharp=5;const tail=sharp*Math.exp(1-sharp);return k=>{if(k<=0)return 0;if(k>=1)return 1;if(kk=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return.4*Math.pow(t,2.5)}if(k<.48){const t=(k-.4)/.08;return.4-.2*t}if(k<.52){const t=(k-.48)/.04;return.2+.8*t}const t=(k-.52)/.48;return 1-.04*Math.sin(t*Math.PI*8)*(1-t)};const rhythmPunchCombo=(peak=.4)=>{const pattern=[{c:.15,w:.04,a:.75},{c:.35,w:.04,a:.75},{c:.7,w:.055,a:1}];return k=>{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of pattern){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return peak*sum}};const rhythmStaccato=(beats=4,duty=.3)=>k=>{if(k<=0||k>=1)return 0;const beatLen=1/beats;const phase=k/beatLen-Math.floor(k/beatLen);if(phase>duty)return 0;const t=phase/duty;return Math.sin(t*Math.PI)};const rhythmKick=(peak=1.2)=>k=>{if(k<=0||k>=1)return 0;if(k<.05)return peak*k/.05;const t=(k-.05)/.95;return peak*Math.exp(-4*t)};const rhythmCrescendo=(beats=4)=>{const centers=[];for(let i=0;i{if(k<=0||k>=1)return 0;let sum=0;for(const{c,w,a}of centers){sum+=a*Math.exp(-((k-c)**2)/(2*w*w))}return sum}};const rhythmDunDunDun=()=>{const bell=(t,c,w)=>Math.exp(-((t-c)**2)/(2*w*w));return k=>{if(k<=0||k>=1)return 0;return.3*bell(k,.15,.025)+.6*bell(k,.35,.03)+1*bell(k,.68,.09)}};const rhythmBellToll=(decay=3,freq=8)=>{const strike=.05;return k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.2){const t=k/.2;return-pressDepth*Math.sin(t*Math.PI/2)}if(k<.5){const t=(k-.2)/.3;return-pressDepth+(pressDepth+reboundPeak)*(1-Math.pow(1-t,3))}const t=(k-.5)/.5;return reboundPeak*Math.exp(-4*t)*Math.cos(t*Math.PI*3)};const uiHoverBloom=(riseRatio=.2,fallRatio=.3)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;const env=1-k;const raw=Math.sin(k*Math.PI*2*count);const clipped=Math.sign(raw)*Math.min(1,Math.abs(raw)*1.8);return amplitude*env*clipped};const uiSuccessPop=(overshoot=.2)=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.4){const t=k/.4;return(1+overshoot)*(1-Math.pow(1-t,2))}const t=(k-.4)/.6;return 1+overshoot*Math.exp(-5*t)*Math.cos(t*Math.PI*3)};const uiRippleOut=()=>k=>{if(k<=0||k>=1)return 0;return 6.75*k*Math.pow(1-k,2)};const UI=Object.freeze({ClickSnap:uiClickSnap(),HoverBloom:uiHoverBloom(),ErrorShake:uiErrorShake(),SuccessPop:uiSuccessPop(),RippleOut:uiRippleOut()});const magicManaCharge=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;const base=(Math.exp(3*k)-1)/(Math.exp(3)-1);const pulse=.04*Math.sin(k*Math.PI*8)*k;return base+pulse};const magicSpellCast=(chargeEnd=.4)=>k=>{if(k<=0||k>=1)return 0;if(kk=>{if(k<=0||k>=1)return 0;if(k<.45){const t=k/.45;return t*t*t}if(k<.55)return 1;const t=(k-.55)/.45;return Math.pow(1-t,3)};const magicShield=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.3){const t=k/.3;return 1.2*(1-Math.pow(1-t,2))}if(k<.6){const t=(k-.3)/.3;return 1.2-.2*t}const t=(k-.6)/.4;return 1+.03*Math.sin(t*Math.PI*3)};const magicAura=(peak=.15)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const fundamental=.6*Math.sin(k*Math.PI*2);const harmonic=.3*Math.sin(k*Math.PI*4+1);const overtone=.1*Math.sin(k*Math.PI*6+2);return peak*env*(fundamental+harmonic+overtone)};const Magic=Object.freeze({ManaCharge:magicManaCharge(),SpellCast:magicSpellCast(),Teleport:magicTeleport(),Shield:magicShield(),MagicAura:magicAura()});const animalCatPounce=()=>k=>{if(k<=0)return 0;if(k>=1)return 1;if(k<.2){const t=k/.2;return-.2*Math.sin(t*Math.PI)}if(k<.3){const t=(k-.2)/.1;return.5*t*t}if(k<.8){const t=(k-.3)/.5;return.5+.5*t+.2*Math.sin(t*Math.PI)}const t=(k-.8)/.2;return 1+.05*Math.sin(t*Math.PI)};const animalBirdFlap=(flaps=4)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const phase=k*Math.PI*2*flaps;const wave=Math.sin(phase)-.3*Math.sin(phase*2);return.2*env*wave};const animalSnakeSlither=(waves=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const wave=Math.sin(k*Math.PI*2*waves);return.2*env*wave};const animalButterflyFlit=(seed=13)=>{let s=seed;const rand=()=>{s=(s*9301+49297)%233280;return s/233280};const samples=[];for(let i=0;i<=26;i++)samples.push(rand()-.5);return k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const pos=k*25;const idx=Math.floor(pos);const t=pos-idx;const smooth=t*t*(3-2*t);const interp=samples[idx]+(samples[idx+1]-samples[idx])*smooth;return.3*env*interp}};const animalHorseGallop=(cycles=3)=>k=>{if(k<=0||k>=1)return 0;const env=Math.sin(k*Math.PI);const cyclePos=k*cycles-Math.floor(k*cycles);const bell=(c,w=.04)=>Math.exp(-((cyclePos-c)**2)/(2*w*w));return.25*env*(bell(0)+bell(.18)+bell(.36)+bell(.54))};const Animal=Object.freeze({CatPounce:animalCatPounce(),BirdFlap:animalBirdFlap(),SnakeSlither:animalSnakeSlither(),ButterflyFlit:animalButterflyFlit(),HorseGallop:animalHorseGallop()});const Progress=Object.freeze({Physics:Object.freeze({...Physics,Spring:libSpring()}),Motion:Motion,Step:Object.freeze({...Step,Steps6:libSteps()}),Math:Object.freeze({Tremor:MathExt.Tremor}),Impact:Object.freeze({Rain:Impact.Rain,Hammer:Impact.Hammer,BounceDrop:Impact.BounceDrop,ArrowHit:Impact.ArrowHit,Shatter:Impact.Shatter}),Rhythm:Object.freeze({BassDrop:Rhythm.BassDrop}),UI:Object.freeze({SuccessPop:UI.SuccessPop}),Magic:Object.freeze({ManaCharge:Magic.ManaCharge,Shield:Magic.Shield}),Animal:Object.freeze({CatPounce:Animal.CatPounce})});const Pulse=Object.freeze({Attention:Object.freeze({Ping:Attention.Ping}),Breath:Object.freeze({Deep:Breath.Deep,Sigh:Breath.Sigh}),Heart:Object.freeze({Calm:Heart.Calm}),Math:Object.freeze({JumpArc:MathExt.JumpArc,BoomerangSharp:mathBoomerang(E.Cubic.In),BoomerangSoft:mathBoomerang(E.Cubic.Out)}),Explosion:Object.freeze({Impulse:Explosion.Impulse,Flash:Explosion.Flash,Recoil:Explosion.Recoil,Implosion:Explosion.Implosion}),Impact:Object.freeze({Slap:Impact.Slap}),Rhythm:Object.freeze({Kick:Rhythm.Kick}),UI:Object.freeze({ClickSnap:UI.ClickSnap,HoverBloom:UI.HoverBloom,RippleOut:UI.RippleOut}),Magic:Object.freeze({SpellCast:Magic.SpellCast,Teleport:Magic.Teleport})});const Wave=Object.freeze({Attention:Object.freeze({Wiggle:Attention.Wiggle,Strum:Attention.Strum}),Breath:Object.freeze({Normal:Breath.Normal,Panting:Breath.Panting}),Heart:Object.freeze({Excited:Heart.Excited,LubDub:Heart.LubDub,Beat:libHeartBeat()}),Math:Object.freeze({Pendulum:MathExt.Pendulum}),Nature:Nature,Rhythm:Object.freeze({PunchCombo:Rhythm.PunchCombo,Staccato:Rhythm.Staccato,Crescendo:Rhythm.Crescendo,DunDunDun:Rhythm.DunDunDun,BellToll:Rhythm.BellToll}),UI:Object.freeze({ErrorShake:UI.ErrorShake}),Magic:Object.freeze({MagicAura:Magic.MagicAura}),Animal:Object.freeze({BirdFlap:Animal.BirdFlap,SnakeSlither:Animal.SnakeSlither,ButterflyFlit:Animal.ButterflyFlit,HorseGallop:Animal.HorseGallop})});const customEasings=Object.freeze({makeOutIn:makeOutIn,OutIn:OutIn,Progress:Progress,Pulse:Pulse,Wave:Wave,cubicBezier:cubicBezier});exports.customEasings=customEasings;exports.default=customEasings; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/CustomShaderPass.js b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/CustomShaderPass.js new file mode 100644 index 0000000000000000000000000000000000000000..d45fb7b6256f868db11b84bb964fa6f29e62ba4c --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/CustomShaderPass.js @@ -0,0 +1 @@ +const THREE=require("../../ThreeJS/three-amg-wrapper.js").THREE;const{ShaderPass}=require("../../ThreeJS/ShaderPass.js");const shaderVertSource=require("./shaders/shaderVert.js").source;const shaderFragSource=require("./shaders/shaderFrag.js").source;function createShader(){const vertexShader=shaderVertSource;const fragmentShader=shaderFragSource;return{name:"CustomShaderPass",uniforms:{tDiffuse:{value:null},tDiffuse1:{value:null},intensity:{value:1},ratio:{value:1},progress:{value:0},shutterCount:{value:6},feather:{value:.08}},vertexShader:vertexShader,fragmentShader:fragmentShader,transparent:true,side:THREE.DoubleSide}}class CustomShaderPass extends ShaderPass{constructor(){super(createShader());this.params={intensity:1,ratio:1,progress:0,shutterCount:6,feather:.08};this._updateShaderUniforms()}_updateShaderUniforms(){this.material.uniforms.intensity.value=this.params.intensity;this.material.uniforms.ratio.value=this.params.ratio;this.material.uniforms.progress.value=this.params.progress;this.material.uniforms.shutterCount.value=this.params.shutterCount;this.material.uniforms.feather.value=this.params.feather}_clampValue(value,min=0,max=1){return Math.max(min,Math.min(max,value))}render(renderer,writeBuffer,readBuffer,delta,maskActive){this._updateShaderUniforms();super.render(renderer,writeBuffer,readBuffer,delta,maskActive)}setParameter(key,value){if(this.params.hasOwnProperty(key)){this.params[key]=value;this.material.uniforms[key].value=value}else{console.warn(`Parameter '${key}' does not exist in this.params`)}}applyPreset(presetName){const preset=this.presets[presetName];if(!preset){console.warn(`Preset '${presetName}' not found`);return}for(const key in preset){if(preset.hasOwnProperty(key)){this.setParameter(key,preset[key])}}}getPresetNames(){return Object.keys(this.presets)}getPresetConfig(presetName){if(!this.presets.hasOwnProperty(presetName)){console.warn(`Preset '${presetName}' not found`);return null}return this.presets[presetName]}}exports.CustomShaderPass=CustomShaderPass; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/atomic.json b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/atomic.json new file mode 100644 index 0000000000000000000000000000000000000000..333be2f1ff58cb2f62e96ca5e1317c8625320312 --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/atomic.json @@ -0,0 +1,61 @@ +{ + "key": "LumiCustom", + "category": "Others", + "desc": "A custom single-pass post effect with intensity, progress, blur, and lighting controls.", + "preset": [ + { + "name": "none", + "desc": "Disables the stylization and preserves the source image as much as possible." + } + ], + "subProperties": [ + { + "name": "intensity", + "desc": "Overall effect-strength control intended for simple host-side animation or mixing.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + }, + { + "name": "ratio", + "desc": "Ratio parameter used to balance or scale the custom effect response.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + }, + { + "name": "progress", + "desc": "Normalized progress control for animating the effect over time.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + }, + { + "name": "blurSize", + "desc": "Parameter controlling blurSize in the LumiCustom effect.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + }, + { + "name": "quality", + "desc": "Internal quality or downsampling control that trades detail for performance.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + }, + { + "name": "lightIntensity", + "desc": "Additional light or highlight intensity used by the custom shader.", + "type": "number", + "value": 0, + "min": 0, + "max": 1 + } + ] +} diff --git a/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/shaders/shaderFrag.js b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/shaders/shaderFrag.js new file mode 100644 index 0000000000000000000000000000000000000000..9bd41ca0818478e3170dab4294b3a0c18a87bb6b --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/shaders/shaderFrag.js @@ -0,0 +1,67 @@ +exports.source=` +//===begin_frag_code=== +precision highp float; + +// 预定义uniform +uniform sampler2D tDiffuse; // 源纹理 +uniform float progress; // = 0.0 [0, 1] +uniform float ratio; // = 1.0 [0.1, 2] +uniform sampler2D tDiffuse1; // 第二个源纹理 + +uniform float shutterCount; // = 6.0 [3.0, 12.0] // 叶片数量 +uniform float feather; // = 0.08 [0.0, 0.3] // 羽化边缘 + +varying vec2 vUv; // 纹理坐标 + +const float PI = 3.14159265; + +vec4 transition(vec4 texel1, vec4 texel2, float progress) { + float eased = smoothstep(0.0, 1.0, progress); + + vec2 centered = vUv - 0.5; + centered.x *= ratio; + float radius = length(centered); + + float angle = atan(centered.y, centered.x); + float angleUnit = (angle + PI) / (2.0 * PI); + float blades = max(3.0, shutterCount); + float rotatedAngle = angleUnit + eased * 0.15; + float patternBase = cos(rotatedAngle * blades * 6.28318530718); + float bladeWave = abs(patternBase); + + float depthMod = mix(1.0, radius * 1.2 + 0.2, eased); + float shaped = clamp(0.3 + 0.7 * bladeWave * depthMod, 0.0, 1.2); + + float radiusLimit = mix(1.35, -0.6 + 0.4 * shaped, eased); + float softness = max(0.0001, feather); + + float reveal = smoothstep(radiusLimit - softness, radiusLimit + softness, radius); + vec4 color = mix(texel1, texel2, clamp(reveal, 0.0, 1.0)); + return color; +} + +void main() { + // Get the pixel color from both textures + vec4 texel1 = texture2D(tDiffuse, vUv); + vec4 texel2 = texture2D(tDiffuse1, vUv); + + // --- Transition Configuration --- + const float fadeInEnd = 0.1; + const float fadeOutStart = 0.9; + + // 1. Calculate the transition's own progress. + float transitionProgress = clamp((progress - fadeInEnd) / (fadeOutStart - fadeInEnd), 0.0, 1.0); + vec4 transitionColor = transition(texel1, texel2, transitionProgress); + + // 2. Calculate smooth blending factors for the start and end zones. + float blendInFactor = smoothstep(0.0, fadeInEnd, progress); + float blendOutFactor = smoothstep(fadeOutStart, 1.0, progress); + + // 3. Apply the blending. + vec4 finalColor = mix(texel1, transitionColor, blendInFactor); + finalColor = mix(finalColor, texel2, blendOutFactor); + + gl_FragColor = finalColor; +} +//===end_frag_code=== +`; \ No newline at end of file diff --git a/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js new file mode 100644 index 0000000000000000000000000000000000000000..2c87ab8ca97aecc86f650141dcf51ecc1ee7f46e --- /dev/null +++ b/scripts/7681304008023215368/AmazingFeature/js/pp/LumiCustom/shaders/shaderVert.js @@ -0,0 +1,8 @@ +exports.source=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`; \ No newline at end of file