|
-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 摄像机FXAA调试界面
|
|
-- *>
|
|
CheatFXAAView = CheatFXAAView or BaseClass(BaseView)
|
|
local CheatFXAAView = CheatFXAAView
|
|
-- local LuminanceMode = FXAAEffect.LuminanceMode
|
|
function CheatFXAAView:__init()
|
|
self.base_file = "cheat"
|
|
self.layout_file = "CheatFXAAView"
|
|
self.layer_name = "Top"
|
|
self.destroy_imm = true
|
|
self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.is_show = true
|
|
self.main_camera = nil
|
|
self.ui_model_camera = nil
|
|
self.setting_errcode = {
|
|
[1] = "当前发布设置的HDR Mode为R11G11B10,无法使用当前明度计算类型",
|
|
[2] = "该明度计算类型无需gamma补偿",
|
|
}
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function CheatFXAAView:Open( )
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function CheatFXAAView:LoadSuccess()
|
|
-- 按钮部分
|
|
self.closeBtn = self:GetChild("closeBtn").gameObject
|
|
self.main_cam_btn = self:GetChild("main_cam_btn").gameObject -- 激活模型摄像机参数界面
|
|
self.ui_cam_btn = self:GetChild("ui_cam_btn").gameObject -- 激活主摄像机参数界面
|
|
self.hideBtn = self:GetChild("hideBtn").gameObject -- 隐藏界面
|
|
-------------------------------------------
|
|
-- 主摄像机参数节点
|
|
self.main_node = self:GetChild("main").gameObject
|
|
self.main_content = self:GetChild("main/Viewport/main_content")
|
|
self.main_enable_toggle = self:GetChild("main/Viewport/main_content/main_enable_toggle"):GetComponent("Toggle")
|
|
-- 主摄对比度阈值
|
|
self.main_c_th_sl = self:GetChild("main/Viewport/main_content/main_c_threshold/main_c_th_sl"):GetComponent("Slider")
|
|
self.main_c_th_val = self:GetChild("main/Viewport/main_content/main_c_threshold/main_c_th_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 主摄相对对比度阈值
|
|
self.main_r_th_sl = self:GetChild("main/Viewport/main_content/main_r_threshold/main_r_th_sl"):GetComponent("Slider")
|
|
self.main_r_th_val = self:GetChild("main/Viewport/main_content/main_r_threshold/main_r_th_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 混合比例
|
|
self.main_sp_b_sl = self:GetChild("main/Viewport/main_content/main_subpix_blend/main_sp_b_sl"):GetComponent("Slider")
|
|
self.main_sp_b_val = self:GetChild("main/Viewport/main_content/main_subpix_blend/main_sp_b_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 低质量步长
|
|
self.main_low_qua_toggle = self:GetChild("main/Viewport/main_content/main_low_qua_toggle"):GetComponent("Toggle")
|
|
-- 主摄FOV
|
|
self.main_cam_fov_sl = self:GetChild("main/Viewport/main_content/main_cam_fov/main_cam_fov_sl"):GetComponent("Slider")
|
|
self.main_cam_fov_val = self:GetChild("main/Viewport/main_content/main_cam_fov/main_cam_fov_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 主摄双重模糊
|
|
self.main_dual_blur_tog = self:GetChild("main/Viewport/main_content/main_dual_blur_tog"):GetComponent("Toggle")
|
|
-- 主摄采样类型
|
|
self.main_combox_node = self:GetChild("main/Viewport/main_content/main_combox")
|
|
|
|
SetSizeDeltaY(self.main_content, 720)
|
|
-------------------------------------------
|
|
-------------------------------------------
|
|
-- 模型摄像机参数节点
|
|
self.ui_node = self:GetChild("ui").gameObject
|
|
self.ui_content = self:GetChild("ui/Viewport/ui_content")
|
|
self.ui_enable_toggle = self:GetChild("ui/Viewport/ui_content/ui_enable_toggle"):GetComponent("Toggle")
|
|
-- 主摄对比度阈值
|
|
self.ui_c_th_sl = self:GetChild("ui/Viewport/ui_content/ui_c_threshold/ui_c_th_sl"):GetComponent("Slider")
|
|
self.ui_c_th_val = self:GetChild("ui/Viewport/ui_content/ui_c_threshold/ui_c_th_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 主摄相对对比度阈值
|
|
self.ui_r_th_sl = self:GetChild("ui/Viewport/ui_content/ui_r_threshold/ui_r_th_sl"):GetComponent("Slider")
|
|
self.ui_r_th_val = self:GetChild("ui/Viewport/ui_content/ui_r_threshold/ui_r_th_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 混合比例
|
|
self.ui_sp_b_sl = self:GetChild("ui/Viewport/ui_content/ui_subpix_blend/ui_sp_b_sl"):GetComponent("Slider")
|
|
self.ui_sp_b_val = self:GetChild("ui/Viewport/ui_content/ui_subpix_blend/ui_sp_b_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 低质量步长
|
|
self.ui_low_qua_toggle = self:GetChild("ui/Viewport/ui_content/ui_low_qua_toggle"):GetComponent("Toggle")
|
|
-- 模摄FOV
|
|
self.ui_cam_fov_sl = self:GetChild("ui/Viewport/ui_content/ui_cam_fov/ui_cam_fov_sl"):GetComponent("Slider")
|
|
self.ui_cam_fov_val = self:GetChild("ui/Viewport/ui_content/ui_cam_fov/ui_cam_fov_val"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- UI摄像机双重模糊
|
|
self.ui_dual_blur_tog = self:GetChild("ui/Viewport/ui_content/ui_dual_blur_tog"):GetComponent("Toggle")
|
|
-- 模摄采样类型
|
|
self.ui_combox_node = self:GetChild("ui/Viewport/ui_content/ui_combox")
|
|
|
|
SetSizeDeltaY(self.ui_content, 720)
|
|
-------------------------------------------
|
|
|
|
SetAnchoredPosition(self.transform, -ClientConfig.iphone_x_offset_right, 0)
|
|
end
|
|
|
|
function CheatFXAAView:AddEvent()
|
|
local function click_event(target)
|
|
if target == self.closeBtn then
|
|
self:Close()
|
|
elseif target == self.main_cam_btn then -- 打开主摄参数面板,下面反之亦然
|
|
self.main_node:SetActive(true)
|
|
self.ui_node:SetActive(false)
|
|
elseif target == self.ui_cam_btn then
|
|
self.main_node:SetActive(false)
|
|
self.ui_node:SetActive(true)
|
|
elseif target == self.hideBtn then -- 隐藏/显示界面
|
|
self:HideAction(not self.is_show)
|
|
-- 主摄参数部分
|
|
elseif target == self.main_enable_toggle.gameObject then -- 启用/禁用FXAA
|
|
if self.main_FXAA then
|
|
self.main_FXAA.EnableFXAA = self.main_enable_toggle.isOn
|
|
end
|
|
elseif target == self.main_low_qua_toggle.gameObject then -- 启用/低质量步长
|
|
if self.main_FXAA then
|
|
self.main_FXAA.lowQuality = self.main_low_qua_toggle.isOn
|
|
end
|
|
-- 模摄参数部分
|
|
elseif target == self.ui_enable_toggle.gameObject then -- 启用/禁用FXAA
|
|
if self.ui_FXAA then
|
|
self.ui_FXAA.EnableFXAA = self.ui_enable_toggle.isOn
|
|
end
|
|
elseif target == self.ui_low_qua_toggle.gameObject then -- 启用/低质量步长
|
|
if self.ui_FXAA then
|
|
self.ui_FXAA.lowQuality = self.ui_low_qua_toggle.isOn
|
|
end
|
|
end
|
|
self:ApplyFXAASetting()
|
|
end
|
|
AddClickEvent(self.closeBtn, click_event)
|
|
AddClickEvent(self.main_cam_btn, click_event)
|
|
AddClickEvent(self.ui_cam_btn, click_event)
|
|
AddClickEvent(self.hideBtn, click_event)
|
|
AddClickEvent(self.main_enable_toggle.gameObject, click_event)
|
|
AddClickEvent(self.main_low_qua_toggle.gameObject, click_event)
|
|
AddClickEvent(self.ui_enable_toggle.gameObject, click_event)
|
|
AddClickEvent(self.ui_low_qua_toggle.gameObject, click_event)
|
|
|
|
local function onSliderDrag(target)
|
|
local value = target:GetComponent("Slider").value
|
|
-- 主摄像机部分
|
|
if target == self.main_c_th_sl.gameObject then
|
|
self.main_c_th_val.text = tonumber(string.format("%.4f", value))
|
|
if self.main_FXAA then
|
|
self.main_FXAA.contrastThreshold = value
|
|
end
|
|
elseif target == self.main_r_th_sl.gameObject then
|
|
self.main_r_th_val.text = tonumber(string.format("%.4f", value))
|
|
if self.main_FXAA then
|
|
self.main_FXAA.relativeThreshold = value
|
|
end
|
|
elseif target == self.main_sp_b_sl.gameObject then
|
|
self.main_sp_b_val.text = tonumber(string.format("%.4f", value))
|
|
if self.main_FXAA then
|
|
self.main_FXAA.subpixelBlending = value
|
|
end
|
|
elseif target == self.main_cam_fov_sl.gameObject then
|
|
self.main_cam_fov_val.text = value
|
|
if self.main_camera then
|
|
self.main_camera.fieldOfView = value
|
|
end
|
|
-- 模型摄像机部分
|
|
elseif target == self.ui_c_th_sl.gameObject then
|
|
self.ui_c_th_val.text = tonumber(string.format("%.4f", value))
|
|
if self.ui_FXAA then
|
|
self.ui_FXAA.contrastThreshold = value
|
|
end
|
|
elseif target == self.ui_r_th_sl.gameObject then
|
|
self.ui_r_th_val.text = tonumber(string.format("%.4f", value))
|
|
if self.ui_FXAA then
|
|
self.ui_FXAA.relativeThreshold = value
|
|
end
|
|
elseif target == self.ui_sp_b_sl.gameObject then
|
|
self.ui_sp_b_val.text = tonumber(string.format("%.4f", value))
|
|
if self.ui_FXAA then
|
|
self.ui_FXAA.subpixelBlending = value
|
|
end
|
|
elseif target == self.ui_cam_fov_sl.gameObject then
|
|
self.ui_cam_fov_val.text = value
|
|
if self.ui_model_camera then
|
|
self.ui_model_camera.fieldOfView = value
|
|
end
|
|
end
|
|
self:ApplyFXAASetting()
|
|
end
|
|
AddDragEvent(self.main_c_th_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.main_r_th_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.main_sp_b_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.main_cam_fov_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.ui_c_th_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.ui_r_th_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.ui_sp_b_sl.gameObject, onSliderDrag)
|
|
AddDragEvent(self.ui_cam_fov_sl.gameObject, onSliderDrag)
|
|
|
|
local function onOrientationChange()
|
|
SetAnchoredPosition(self.transform, -ClientConfig.iphone_x_offset_right, 0)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
|
|
end
|
|
|
|
function CheatFXAAView:UpdateView()
|
|
self:InitCamsData()
|
|
-- self:InitLuminanceCombox()
|
|
self.main_node:SetActive(true)
|
|
self.ui_node:SetActive(false)
|
|
self:HideAction(true)
|
|
end
|
|
|
|
function CheatFXAAView:InitCamsData( )
|
|
-- 获取摄像机
|
|
if not self.main_camera then
|
|
self.main_camera = MainCamera.Instance.camera
|
|
end
|
|
if not self.ui_model_camera then
|
|
self.ui_model_camera = GameObject.Find("root").transform:Find("UIBackRoleCamera"):GetComponent("Camera")
|
|
end
|
|
-- 获取FXAA类
|
|
if not self.main_FXAA then
|
|
self.main_FXAA = self.main_camera.gameObject:GetComponent(typeof(PostEffect))
|
|
end
|
|
if not self.ui_FXAA then
|
|
self.ui_FXAA = self.ui_model_camera.gameObject:GetComponent(typeof(PostEffect))
|
|
end
|
|
-- 初始化摄像机参数和FXAA参数
|
|
self.main_enable_toggle.isOn = self.main_FXAA.EnableFXAA
|
|
self.main_c_th_sl.value = self.main_FXAA.contrastThreshold
|
|
self.main_c_th_val.text = tonumber(string.format("%.4f", self.main_FXAA.contrastThreshold))
|
|
self.main_r_th_sl.value = self.main_FXAA.relativeThreshold
|
|
self.main_r_th_val.text = tonumber(string.format("%.4f", self.main_FXAA.relativeThreshold))
|
|
self.main_sp_b_sl.value = self.main_FXAA.subpixelBlending
|
|
self.main_sp_b_val.text = tonumber(string.format("%.4f", self.main_FXAA.subpixelBlending))
|
|
self.main_low_qua_toggle.isOn = self.main_FXAA.lowQuality
|
|
self.main_cam_fov_sl.value = self.main_camera.fieldOfView
|
|
self.main_cam_fov_val.text = self.main_camera.fieldOfView
|
|
|
|
|
|
self.ui_enable_toggle.isOn = self.ui_FXAA.EnableFXAA
|
|
self.ui_c_th_sl.value = self.ui_FXAA.contrastThreshold
|
|
self.ui_c_th_val.text = tonumber(string.format("%.4f", self.ui_FXAA.contrastThreshold))
|
|
self.ui_r_th_sl.value = self.ui_FXAA.relativeThreshold
|
|
self.ui_r_th_val.text = tonumber(string.format("%.4f", self.ui_FXAA.relativeThreshold))
|
|
self.ui_sp_b_sl.value = self.ui_FXAA.subpixelBlending
|
|
self.ui_sp_b_val.text = tonumber(string.format("%.4f", self.ui_FXAA.subpixelBlending))
|
|
self.ui_low_qua_toggle.isOn = self.ui_FXAA.lowQuality
|
|
self.ui_cam_fov_sl.value = self.ui_model_camera.fieldOfView
|
|
self.ui_cam_fov_val.text = self.ui_model_camera.fieldOfView
|
|
end
|
|
|
|
function CheatFXAAView:ApplyFXAASetting( )
|
|
local function apply_setting()
|
|
if self.main_FXAA then
|
|
self.main_FXAA:ApplyFXAAMaterialProperties()
|
|
end
|
|
if self.ui_FXAA then
|
|
self.ui_FXAA:ApplyFXAAMaterialProperties()
|
|
end
|
|
end
|
|
TimeManager.GetInstance():StartTime("CheatFXAAView_ApplyFXAASetting", 0.5, apply_setting)
|
|
end
|
|
|
|
-- -- 初始化明度计算下拉框
|
|
-- function CheatFXAAView:InitLuminanceCombox(just_reselect)
|
|
-- local list = {
|
|
-- {luminanceMode = LuminanceMode.Alpha},
|
|
-- {luminanceMode = LuminanceMode.Green},
|
|
-- {luminanceMode = LuminanceMode.Calculate},
|
|
-- }
|
|
-- local combox_str_list = {
|
|
-- "Alpha",
|
|
-- "Green",
|
|
-- "Calculate",
|
|
-- }
|
|
-- self.cur_main_lm_mode_index = 1
|
|
-- if self.main_FXAA.luminanceSource == LuminanceMode.Green then
|
|
-- self.cur_main_lm_mode_index = 2
|
|
-- elseif self.main_FXAA.luminanceSource == LuminanceMode.Calculate then
|
|
-- self.cur_main_lm_mode_index = 3
|
|
-- end
|
|
-- local function update_main_luminance_func(index)
|
|
-- self.cur_main_lm_mode_index = index
|
|
-- self.main_FXAA.luminanceSource = list[index].luminanceMode
|
|
-- -- self:ApplySetting()
|
|
-- end
|
|
-- local main_prefab_data = {Combox = "Combox",ComboxView = "ComboxView", ComboxItem = "ComboxItem", offset_y = -#list*ComboxItem.Height-9}
|
|
-- if not self.main_combox then
|
|
-- self.main_combox = Combox.New(self.main_combox_node, combox_str_list, update_main_luminance_func, 122, 38, nil, main_prefab_data, self.layer_name)
|
|
-- SetAnchoredPositionX(self.main_combox.transform, 0, 0)
|
|
-- self.main_combox:ResetData(combox_str_list, self.cur_main_lm_mode_index, update_main_luminance_func, 122, 38, nil, true)
|
|
-- else
|
|
-- self.main_combox:ResetData(combox_str_list, self.cur_main_lm_mode_index, update_main_luminance_func, 122, 38, nil, just_reselect)
|
|
-- end
|
|
|
|
-- self.cur_ui_lm_mode_index = 1
|
|
-- if self.ui_FXAA.luminanceSource == LuminanceMode.Green then
|
|
-- self.cur_ui_lm_mode_index = 2
|
|
-- elseif self.ui_FXAA.luminanceSource == LuminanceMode.Calculate then
|
|
-- self.cur_ui_lm_mode_index = 3
|
|
-- end
|
|
-- local function update_ui_luminance_func(index)
|
|
-- self.cur_ui_lm_mode_index = index
|
|
-- self.ui_FXAA.luminanceSource = list[index].luminanceMode
|
|
-- -- self:ApplySetting()
|
|
-- end
|
|
-- local ui_prefab_data = {Combox = "Combox",ComboxView = "ComboxView", ComboxItem = "ComboxItem", offset_y = -#list*ComboxItem.Height-9}
|
|
-- if not self.ui_combox then
|
|
-- self.ui_combox = Combox.New(self.ui_combox_node, combox_str_list, update_ui_luminance_func, 122, 38, nil, ui_prefab_data, self.layer_name)
|
|
-- SetAnchoredPositionX(self.ui_combox.transform, 0, 0)
|
|
-- self.ui_combox:ResetData(combox_str_list, self.cur_ui_lm_mode_index, update_ui_luminance_func, 122, 38, nil, true)
|
|
-- else
|
|
-- self.ui_combox:ResetData(combox_str_list, self.cur_ui_lm_mode_index, update_ui_luminance_func, 122, 38, nil, just_reselect)
|
|
-- end
|
|
-- end
|
|
|
|
function CheatFXAAView:HideAction(show)
|
|
self.is_show = show
|
|
-- SetLocalRotation(self.hideBtn.transform, 0, 0, self.is_show and 90 or 270)
|
|
self.hideBtn.transform.localRotation = Quaternion.Euler(Vector3(0, 0, self.is_show and 90 or 270))
|
|
local target_pos_x = (self.is_show and 0 or 366 ) - ClientConfig.iphone_x_offset_right
|
|
self.con_anim_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX, target_pos_x, 0.3, nil, TweenFunc.EASE_OUT_QUINT)
|
|
end
|
|
|
|
-- function CheatFXAAView:ApplySetting( )
|
|
-- local errcode, err_msg
|
|
-- if self.main_FXAA then
|
|
-- errcode = self.main_FXAA:ApplySetting()
|
|
-- err_msg = self.setting_errcode[errcode]
|
|
-- if err_msg then
|
|
-- print("Saber:CheatFXAAView [start:306] ------------------------------------------")
|
|
-- Message.show(err_msg, "fault")
|
|
-- end
|
|
-- end
|
|
-- if self.ui_FXAA then
|
|
-- errcode = self.ui_FXAA:ApplySetting()
|
|
-- err_msg = self.setting_errcode[errcode]
|
|
-- if err_msg then
|
|
-- print("Saber:CheatFXAAView [start:314] ------------------------------------------")
|
|
-- Message.show(err_msg, "fault")
|
|
-- end
|
|
-- end
|
|
-- self:InitCamsData()
|
|
-- self:InitLuminanceCombox(true)
|
|
-- end
|
|
|
|
function CheatFXAAView:StopHideAction( )
|
|
if self.con_anim_id then
|
|
TweenLite.Stop(self.con_anim_id)
|
|
SetAnchoredPositionX(self.transform, (self.is_show and 0 or 366 ) - ClientConfig.iphone_x_offset_right)
|
|
end
|
|
end
|
|
|
|
function CheatFXAAView:DestroySuccess( )
|
|
self:StopHideAction()
|
|
end
|