블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2741)
Unity3D (30)
Programming (475)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (54)
Android (15)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
05-20 02:12

[요약1] Chrome-설정(⋮)-도구 더보기-개발자 도구(F12)-톱니바퀴(Settings)-Prefrences-Debugger-Disable JavaScript 체크

[요약2] https://chromewebstore.google.com/detail/simple-allow-copy/aefehdhdciieocakfobpaaolhipkcpgc

 

Simple Allow Copy

Allow Copy on every websites

chrome.google.com

 

[링크] https://bbomee.tistory.com/entry/%EC%9D%B8%ED%84%B0%EB%84%B7-%EC%9B%B9%ED%8E%98%EC%9D%B4%EC%A7%80-%EB%B3%B5%EC%82%AC%EB%B0%A9%EC%A7%80-%ED%95%B4%EC%A0%9C-%ED%81%AC%EB%A1%AC-%ED%99%95%EC%9E%A5%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8-%EC%84%A4%EC%B9%98%EB%A1%9C-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B0

 

인터넷 웹페이지 복사방지 해제, 크롬 확장프로그램 설치로 해결하기

간혹 중요 내용의 뉴스를 보고 다음에 활용을 위해서 또는 인용을 위해 꼭 복사하기가 필요한 경우 복사하기 차단이 되었을 시 오른쪽 마우스 복사하기 안됩니다. 이런 경우 복사할 수 있는 방

bbomee.tistory.com

 

 

 

반응형
Posted by blueasa
, |
// jave.lin 2022.03.17

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

// jave.lin : 输出系统的信息工具类
public class DumpSystemInfoUtil
{
    // jave.lin : 通过反射得方式获取不了
    public static string DumpSystemInfoByReflection()
    {
        var type = typeof(SystemInfo);
        // jave.lin : 下面发现反射不成功
        var fields = type.GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
        var fieldsToStrList = new List<string>();
        foreach (var field in fields)
        {
            // 过滤 过期得 API
            var obsoAttris = field.GetCustomAttributes(typeof(ObsoleteAttribute), true);
            if (obsoAttris != null && obsoAttris.Length > 0) continue;
            fieldsToStrList.Add(field.Name + ":" + field.GetValue(null).ToString());
        }
        return string.Join("\n", fieldsToStrList.ToArray());
    }

    // jave.lin : 所以只能通过一个个得去输出
    public static string DumpSystemInfoByManualyPrint()
    {
        var list = new List<string>(
            new string[]{
                "SystemInfo:\n",
                "\tbatteryLevel:" + SystemInfo.batteryLevel,
                "\tbatteryStatus:" + SystemInfo.batteryStatus,
                "\toperatingSystem:" + SystemInfo.operatingSystem,
                "\toperatingSystemFamily:" + SystemInfo.operatingSystemFamily,
                "\tprocessorType:" + SystemInfo.processorType,
                "\tprocessorFrequency:" + SystemInfo.processorFrequency,
                "\tprocessorCount:" + SystemInfo.processorCount,
                "\tsystemMemorySize:" + SystemInfo.systemMemorySize,
                "\tdeviceUniqueIdentifier:" + SystemInfo.deviceUniqueIdentifier,
                "\tdeviceName:" + SystemInfo.deviceName,
                "\tdeviceModel:" + SystemInfo.deviceModel,
                "\tsupportsAccelerometer:" + SystemInfo.supportsAccelerometer,
                "\tsupportsGyroscope:" + SystemInfo.supportsGyroscope,
                "\tsupportsLocationService:" + SystemInfo.supportsLocationService,
                "\tsupportsVibration:" + SystemInfo.supportsVibration,
                "\tsupportsAudio:" + SystemInfo.supportsAudio,
                "\tdeviceType:" + SystemInfo.deviceType,
                "\tgraphicsMemorySize:" + SystemInfo.graphicsMemorySize,
                "\tgraphicsDeviceName:" + SystemInfo.graphicsDeviceName,
                "\tgraphicsDeviceVendor:" + SystemInfo.graphicsDeviceVendor,
                "\tgraphicsDeviceID:" + SystemInfo.graphicsDeviceID,
                "\tgraphicsDeviceVendorID:" + SystemInfo.graphicsDeviceVendorID,
                "\tgraphicsDeviceType:" + SystemInfo.graphicsDeviceType,
                "\tgraphicsUVStartsAtTop:" + SystemInfo.graphicsUVStartsAtTop,
                "\tgraphicsDeviceVersion:" + SystemInfo.graphicsDeviceVersion,
                "\tgraphicsShaderLevel:" + SystemInfo.graphicsShaderLevel,
                "\tgraphicsMultiThreaded:" + SystemInfo.graphicsMultiThreaded,
                "\tsupportsShadows:" + SystemInfo.supportsShadows,
                "\tsupportsRawShadowDepthSampling:" + SystemInfo.supportsRawShadowDepthSampling,
                "\tsupportsMotionVectors:" + SystemInfo.supportsMotionVectors,
                "\tsupports3DTextures:" + SystemInfo.supports3DTextures,
                "\tsupports2DArrayTextures:" + SystemInfo.supports2DArrayTextures,
                "\tsupports3DRenderTextures:" + SystemInfo.supports3DRenderTextures,
                "\tsupportsCubemapArrayTextures:" + SystemInfo.supportsCubemapArrayTextures,
                "\tcopyTextureSupport:" + SystemInfo.copyTextureSupport,
                "\tsupportsComputeShaders:" + SystemInfo.supportsComputeShaders,
                "\tsupportsInstancing:" + SystemInfo.supportsInstancing,
                "\tsupportsHardwareQuadTopology:" + SystemInfo.supportsHardwareQuadTopology,
                "\tsupports32bitsIndexBuffer:" + SystemInfo.supports32bitsIndexBuffer,
                "\tsupportsSparseTextures:" + SystemInfo.supportsSparseTextures,
                "\tsupportedRenderTargetCount:" + SystemInfo.supportedRenderTargetCount,
                "\tsupportsMultisampledTextures:" + SystemInfo.supportsMultisampledTextures,
                "\tsupportsMultisampleAutoResolve:" + SystemInfo.supportsMultisampleAutoResolve,
                "\tsupportsTextureWrapMirrorOnce:" + SystemInfo.supportsTextureWrapMirrorOnce,
                "\tusesReversedZBuffer:" + SystemInfo.usesReversedZBuffer,
                "\tnpotSupport:" + SystemInfo.npotSupport,
                "\tmaxTextureSize:" + SystemInfo.maxTextureSize,
                "\tmaxCubemapSize:" + SystemInfo.maxCubemapSize,
                "\tsupportsAsyncCompute:" + SystemInfo.supportsAsyncCompute,
                "\tsupportsAsyncGPUReadback:" + SystemInfo.supportsAsyncGPUReadback,
                "\tsupportsMipStreaming:" + SystemInfo.supportsMipStreaming,
            });
        return string.Join("\n", list.ToArray());
    }
}

// jave.lin : 设备定档级别枚举
public enum eDeviceLevel
{
    Unknow = -1,
    VeryLow = 0,
    Low,
    Middle,
    High,
}

// jave.lin : 画质级别
public enum eQualityLevel
{
    Low = 1,
    Middle = 2,
    High = 3,
    Ultra = 4,
}

// jave.lin : shader lod
public enum eShaderLOD
{
    //High = 800,
    //Middle = 400,
    //Low = 200,
    //VeryLow = 100,
    //UnLimit = -1,
    // jave.lin : 太低的值对 built-in shader 的影响太大
    High = 800,
    Middle = 600,
    Low = 400,
    VeryLow = 200,
    UnLimit = -1,
}

// jave.lin : 游戏的质量设置类
public class GameQualitySettings
{
    private const string QS_POWER_SAVE_MODE_KEY = "graphics_setting.power_save_mode";
    private const string QS_QUALITY_LEVEL_KEY = "graphics_setting.quality_level";

    // 当 品质有调整事出发的事件函数
    public static Action<eQualityLevel> onLevelChanged;

    // 源来的 AA 和 阴影设置
    private static int srcAntiAliasing;
    private static ShadowQuality srcShadows;

    // 当前 品质等级
    private static eQualityLevel curLevel;

    // 获取 设备定档的质量级别
    public static eQualityLevel DeviceAdapterLevel
    {
        get; private set;
    }

    // 获取 或 设置 公开给外部的画质设置的属性
    public static eQualityLevel GraphicsLevel
    {
        get { return curLevel; }
        set
        {
            if (curLevel != value)
            {
                curLevel = value;
                _SetCurLevel(value);
                PlayerPrefs.SetInt(QS_QUALITY_LEVEL_KEY, (int)value);
                if (null != onLevelChanged)
                {
                    onLevelChanged.Invoke(value);
                }
            }
        }
    }

    // 获取 或 设置 省电模式, true: 30FPS, false: 60FPS
    public static bool PowerSaveMode
    {
        get
        {
            return Application.targetFrameRate < 40;
        }

        set
        {
            var src_v = PlayerPrefs.GetInt(QS_POWER_SAVE_MODE_KEY, -1);
            var tar_v = value ? 1 : 0;
            if (src_v != tar_v)
            {
                PlayerPrefs.SetInt(QS_POWER_SAVE_MODE_KEY, tar_v);
            }
            Application.targetFrameRate = value ? 30 : 60;
        }
    }

    // 静态构造函数
    static GameQualitySettings()
    {
        // 备份 原始 AA 和 阴影
        srcAntiAliasing = QualitySettings.antiAliasing;
        srcShadows = QualitySettings.shadows;

        // 初始化 品质 和 省电模式
        _SetDefaultPowerSaveMode();
        _SetDefaultLevel();
    }

    // 设置默认的品质等级
    private static void _SetDefaultLevel()
    {
        // 先 分析 并 设置 设备默认品质等级
        DeviceAdapterLevel = _AnalysicDeviceLevel();

        var src_v = PlayerPrefs.GetInt(QS_QUALITY_LEVEL_KEY, -1);
        // 如果品质等级没有设置过
        if (src_v == -1)
        {
            // 那么使用 设备默认品质
            PlayerPrefs.SetInt(QS_QUALITY_LEVEL_KEY, (int)DeviceAdapterLevel);
            curLevel = GraphicsLevel;
        }
        // 如果品质等级有设置过
        else
        {
            curLevel = (eQualityLevel)src_v;
        }
    }

    // 设置默认的省电模式
    private static void _SetDefaultPowerSaveMode()
    {
        var src_v = PlayerPrefs.GetInt(QS_POWER_SAVE_MODE_KEY, 0);
        if (src_v == 0)
        {
            PowerSaveMode = true;
            PlayerPrefs.SetInt(QS_POWER_SAVE_MODE_KEY, 1);
        }
        else
        {
            PowerSaveMode = src_v == 1;
        }
    }

    // 分析设备所属默认的品质等级
    private static eQualityLevel _AnalysicDeviceLevel()
    {
        if (SystemInfo.processorFrequency >= 2500 &&
            SystemInfo.processorCount >= 8 &&
            SystemInfo.systemMemorySize >= (6 * 1024) &&
            SystemInfo.graphicsMemorySize >= (2 * 1024) &&
            SystemInfo.graphicsShaderLevel >= 30 &&
            SystemInfo.graphicsMultiThreaded &&
            SystemInfo.supportsShadows &&
            SystemInfo.supportsInstancing &&
            SystemInfo.supports32bitsIndexBuffer
            )
        {
            return eQualityLevel.Ultra;
        }
        else if (SystemInfo.processorFrequency >= 2000 &&
            SystemInfo.processorCount >= 4 &&
            SystemInfo.systemMemorySize >= (4 * 1024) &&
            SystemInfo.graphicsMemorySize >= (1 * 1024) &&
            SystemInfo.graphicsShaderLevel >= 20
            )
        {
            return eQualityLevel.High;
        }
        else if (SystemInfo.processorFrequency >= 1500 &&
            SystemInfo.processorCount >= 2 &&
            SystemInfo.systemMemorySize >= (2 * 1024) &&
            SystemInfo.graphicsMemorySize >= (512) &&
            SystemInfo.graphicsShaderLevel >= 10
            )
        {
            return eQualityLevel.Middle;
        }
        else
        {
            return eQualityLevel.Low;
        }
    }

    // 设置 当前品质等级
    private static void _SetCurLevel(eQualityLevel level)
    {
        _SetAntiAliasing(level);
        _SetResolution(level);
        _SetTexMipmapOffset(level);
        _SetShadow(level);
        _SetLODBias(level);
        _SetGraphicsTier(level);
        _SetShaderLOD(level);
        _SetGlobalShaderKW(level);
    }

    // 设置 AA
    private static void _SetAntiAliasing(eQualityLevel level)
    {
        if (level >= eQualityLevel.High)
        {
            QualitySettings.antiAliasing = srcAntiAliasing;
        }
        else
        {
            QualitySettings.antiAliasing = 0;
        }
    }

    // 设置分辨率
    private static void _SetResolution(eQualityLevel level)
    {
        // jave.lin : BRP(Built-In Rendering Pipeline) 中
        // 需要对应的 Camera 开启 AllowDynamicResolution 后才能生效
        switch (level)
        {
            case eQualityLevel.Low:
                QualitySettings.resolutionScalingFixedDPIFactor = 0.75f;
                break;
            case eQualityLevel.Middle:
                QualitySettings.resolutionScalingFixedDPIFactor = 0.85f;
                break;
            case eQualityLevel.High:
                QualitySettings.resolutionScalingFixedDPIFactor = 0.85f;
                break;
            case eQualityLevel.Ultra:
                QualitySettings.resolutionScalingFixedDPIFactor = 1.00f;
                break;
        }
    }

    // 设置 Tex 纹理 mipmap offset
    private static void _SetTexMipmapOffset(eQualityLevel level)
    {
        switch (level)
        {
            case eQualityLevel.Low:
                QualitySettings.masterTextureLimit = DeviceAdapterLevel < eQualityLevel.High ? 3 : 2;
                break;
            case eQualityLevel.Middle:
                QualitySettings.masterTextureLimit = DeviceAdapterLevel < eQualityLevel.High ? 2 : 1;
                break;
            case eQualityLevel.High:
                QualitySettings.masterTextureLimit = 0;
                break;
            case eQualityLevel.Ultra:
                QualitySettings.masterTextureLimit = 0;
                break;
        }
    }

    // 设置阴影
    private static void _SetShadow(eQualityLevel level)
    {
        switch (level)
        {
            case eQualityLevel.Low:
            case eQualityLevel.Middle:
                //QualitySettings.shadows = ShadowQuality.Disable; // jave.lin : 有 BUG,会导致,Animator 组件中的 culling mode 不是 always animated 的对象超出屏幕的画,会被自动停止掉
                // 所以下面使用 shadowDistance 来替代关闭
                QualitySettings.shadowDistance = 0;
                break;
            case eQualityLevel.High:
                QualitySettings.shadows = srcShadows;
                QualitySettings.shadowResolution = ShadowResolution.Low;
                QualitySettings.shadowDistance = 70;
                break;
            case eQualityLevel.Ultra:
                QualitySettings.shadows = srcShadows;
                QualitySettings.shadowResolution = ShadowResolution.High;
                QualitySettings.shadowDistance = 100;
                break;
        }
    }

    // 设置 LOD 偏移
    private static void _SetLODBias(eQualityLevel level)
    {
        switch (level)
        {
            case eQualityLevel.Low:
                QualitySettings.lodBias = 0.5f;
                break;
            case eQualityLevel.Middle:
                QualitySettings.lodBias = 0.75f;
                break;
            case eQualityLevel.High:
            case eQualityLevel.Ultra:
                QualitySettings.lodBias = 1.0f;
                break;
        }
    }

    // 设置 GraphicsTier 的层级
    private static void _SetGraphicsTier(eQualityLevel level)
    {
        switch (level)
        {
            case eQualityLevel.Low:
            case eQualityLevel.Middle:
                Graphics.activeTier = GraphicsTier.Tier1;
                break;
            case eQualityLevel.High:
                Graphics.activeTier = GraphicsTier.Tier2;
                break;
            case eQualityLevel.Ultra:
                Graphics.activeTier = GraphicsTier.Tier3;
                break;
        }
    }

    // 设置 Shader LOD
    private static void _SetShaderLOD(eQualityLevel level)
    {
        switch (level)
        {
            case eQualityLevel.Low:
                Shader.globalMaximumLOD = (int)eShaderLOD.VeryLow;
                break;
            case eQualityLevel.Middle:
                Shader.globalMaximumLOD = (int)eShaderLOD.Low;
                break;
            case eQualityLevel.High:
                Shader.globalMaximumLOD = (int)eShaderLOD.Middle;
                break;
            case eQualityLevel.Ultra:
                Shader.globalMaximumLOD = (int)eShaderLOD.High;
                break;
            default:
                Shader.globalMaximumLOD = (int)eShaderLOD.UnLimit;
                break;
        }
    }

    // 设置全局Shader Keyword
    private static void _SetGlobalShaderKW(eQualityLevel level)
    {
        switch (level)
        {
            case eQualityLevel.Low:
            case eQualityLevel.Middle:
                Shader.DisableKeyword("_SOFT_PARTICLE_ON");
                break;
            case eQualityLevel.High:
            case eQualityLevel.Ultra:
                Shader.EnableKeyword("_SOFT_PARTICLE_ON");
                break;
        }
    }
}

// jave.lin : 后效基类
public class PPBasic : MonoBehaviour { }
// jave.lin : Bloom 后效
public class BloomPP : PPBasic
{
    // jave.lin : start 时 先处理,处理当前品质
    // 然后监听 品质变化的时间
    private void Start()
    {
        OnQualityLevelChanged(GameQualitySettings.GraphicsLevel);
        GameQualitySettings.onLevelChanged -= OnQualityLevelChanged;
        GameQualitySettings.onLevelChanged += OnQualityLevelChanged;
    }
    // jave.lin : 销毁时记得删除回调
    private void OnDestroy()
    {
        GameQualitySettings.onLevelChanged -= OnQualityLevelChanged;
    }

    private void OnQualityLevelChanged(eQualityLevel ql)
    {
        // jave.lin : 当 品质等级大于或等于高时,才开启 Bloom 后效
        enabled = ql >= eQualityLevel.High;
    }
}

 

 

[출처] https://blog.csdn.net/linjf520/article/details/123546253

 

Unity - 画质设置_unity systeminfo.processorfrequency 值大于5000mhz-CSDN博客

Show me Your Code, Talk Is Cheap. 以前自己写的类,现在重新写一份 代码 便于日后直接搬运使用,代码都是相当简单,都是直接调用 unity 的 API 设置即可,可以理解为就是搬运而已 环境 Unity : 2018.2.11f1

blog.csdn.net

 

반응형
Posted by blueasa
, |

Unity 2021.3.33f1

----

 

앱 최초 실행 시, 최적화를 위해 그래픽 품질 관련 자동 설정하는 기능을 찾아보다 적용하고 올려 둠.

 

참조한 글을 보니 기본적으로 유니티 SystemInfo에서 지원하는 하드웨어 스펙을 보고 판단해서 Quality Level을 메기고 있다.

해당 레벨은 Unity의 UnityEngine.QualityLevel을 참조하고 있어서 대응 하는 enum을 추가(eQualityLevel)하고,

60프레임을 사용하기 위해 해당 부분 값만 수정했다.

 

필요할 때 AutoChooseQualityLevel()을 호출하고, 반환 받은 eQualityLevel 값에 따라 원하는 설정을 적용해주면 된다.

/// <summary>
/// UnityEngine.QualityLevel에 대응하는 enum
/// </summary>
public enum eQualityLevel : int 
{
    Fastest,
    Fast,
    Simple,
    Good,       // [참고] PC(i7-10700/64GB/RTX3700)에서 Good 나옴
    Beautiful,
    Fantastic
}

private eQualityLevel AutoChooseQualityLevel()
{
    Debug.Assert(Enum.GetNames(typeof(QualityLevel)).Length == Enum.GetNames(typeof(eQualityLevel)).Length, "Please update eQualityLevel to the new quality levels.");

	var shaderLevel = SystemInfo.graphicsShaderLevel;
    var cpus = SystemInfo.processorCount;
    var vram = SystemInfo.graphicsMemorySize;
    var fillrate = 0;

    // ShaderLevel
    if (shaderLevel < 10)
    	fillrate = 1000;
    else if (shaderLevel < 20)
    	fillrate = 1300;
    else if (shaderLevel < 30)
    	fillrate = 2000;
    else
    	fillrate = 3000;
    // CPU Count
    if (6 <= cpus)
    	fillrate *= 3;
    else if (3 <= cpus)
    	fillrate *= 2;
    // VRam
    if (512 <= vram)
    	fillrate *= 2;
    else if (vram <= 128)
    	fillrate /= 2;
        
    var resx = Screen.width;
    var resy = Screen.height;
    var target_fps = 60.0f;		// 현재 게임의 타겟 프레임에 맞게 설정
    var fillneed = (resx * resy + 400f * 300f) * (target_fps / 1000000.0f);
    // Change the values in levelmult to match the relative fill rate
    // requirements for each quality level.
    var levelmult = new float[] { 5.0f, 30.0f, 80.0f, 130.0f, 200.0f, 320.0f };

    const int max_quality = (int)eQualityLevel.Fantastic;
    var level = 0;
    while (level < max_quality && fillneed * levelmult[level + 1] < fillrate)
        ++level;

    var quality = (eQualityLevel)level;
    Debug.Log(string.Format("{0}x{1} need {2} has {3} = {4} level", resx, resy, fillneed, fillrate, quality.ToString()));

    return quality;
}

 

 

P.s. 참조 글 중에 에셋도 적혀있긴한데 사서 써보진 않음.

 

 

[참조] https://stackoverflow.com/questions/20978106/automatic-quality-settings/20978462#20978462

 

Automatic quality settings

a lot of apps that I see nowadays(Android) instead of having an options screen to select the graphical level, it just automatically does it, I know this is kind of a vast question, but how can I do...

stackoverflow.com

 

[참조] https://discussions.unity.com/t/auto-detect-quality-settings/24351

 

auto detect quality settings

is there a way that unity can auto detect client GPU/CPU capability and performance to set best quality settings?

discussions.unity.com

 

[에셋] https://assetstore.unity.com/packages/tools/integration/auto-quality-hardware-assessment-tool-aqhat-74134

 

Auto Quality Hardware Assessment Tool - AQHAT | 기능 통합 | Unity Asset Store

Use the Auto Quality Hardware Assessment Tool - AQHAT from Eager Amoeba® on your next project. Find this integration tool & more on the Unity Asset Store.

assetstore.unity.com

 

반응형
Posted by blueasa
, |