local exports = exports or {} local BlurControl = BlurControl or {} BlurControl.__index = BlurControl function BlurControl.new(construct, ...) local self = setmetatable({}, BlurControl) self.comps = {} self.compsdirty = true return self end function BlurControl:constructor() end function BlurControl:onComponentAdded(sys, comp) end function BlurControl:onComponentRemoved(sys, comp) end function BlurControl:onStart(sys) self.width = 0 self.height = 0 end function BlurControl:onUpdate(sys,deltaTime) local height = Amaz.BuiltinObject:getOutputTextureHeight() local width = Amaz.BuiltinObject:getOutputTextureWidth() -- local _width = Amaz.BuiltinObject:getInputTextureWidth() -- local _height = Amaz.BuiltinObject:getInputTextureHeight() -- print(string.format("GPU scale width:%d height: %d\n", _width, self.height) ) if self.width ~= width or self.height ~= height then self.width = width self.height = height local scale = 0.2 local blurEnt = sys.scene:findEntityBy("BloomBlur") if blurEnt then local mat = blurEnt:getComponent("MeshRenderer").material if mat then mat:setFloat("texelHeightOffset", 1.0 / self.height / scale) mat:setFloat("texelWidthOffset", 1.0 / self.width / scale) -- print(string.format("GPU scale width:%d height: %d\n", self.width * scale, self.height * scale) ) end end end end exports.BlurControl = BlurControl return exports