Unity性能优化-降低功耗,发热量,耗电量之OnDemandRendering篇

公司游戏项目,手机运行严重发烫,耗电量飞快。在暂时无法做其他美术性和技术性优化的情况下,我写了这个公司内部文档,并做了个实验,今天干脆公布出来,希望对大家有用。

--官方文档:

Unity - Scripting API: OnDemandRendering

--Youtube讲解:

https://www.youtube.com/watch?v=RYgWn6jbteY

youtube上的极端实验结果:

 

好,现在我们来做一下实验,看把渲染帧率从60,动态降低到12左右,手机耗电量会降低多少,温度是否能降低。

第一次测试:

我们把如下代码挂到场景中任意一个游戏体,设置渲染帧率60的情况下:

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


public class Change_Frame : MonoBehaviour
{

    // 目标帧率
    public int FrameRate = 60;


    // Start is called before the first frame update
    void Start()
    {
        //QualitySettings.vSyncCount = 0;
        Application.targetFrameRate = FrameRate;
        // 降低帧率
        // If there isn't any input then we can go back to 12 FPS (every 5 frames).
        // OnDemandRendering.renderFrameInterval = 5;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

开始测试,手机电量为78%,测试开始时间,8:27,如下:

 结束测试,手机电量为72%,测试结束时间,8:42,如下:

 第一次测试结论:

测试时长:15分钟,耗电量6%,手机明显发热,略烫手,肯定是40度以上。

第二次测试:

我们把代码改一下,其实就是取消OnDemandRendering.renderFrameInterval = 5; 的注释,把渲染帧率设置为12:

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


public class Change_Frame : MonoBehaviour
{

    // 目标帧率
    public int FrameRate = 60;


    // Start is called before the first frame update
    void Start()
    {
        //QualitySettings.vSyncCount = 0;
        Application.targetFrameRate = FrameRate;
        // 降低帧率
        // If there isn't any input then we can go back to 12 FPS (every 5 frames).
        OnDemandRendering.renderFrameInterval = 5;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

开始测试,手机电量为71%,测试开始时间,9:00,如下:

结束测试,手机电量为72%,测试结束时间,8:42,如下:

 第二次测试结论:

测试时长:15分钟,耗电量3%,手机不怎么发热,感觉在室温左右,总之肯定低于36度。

 

 结论:

使用OnDemandRendering可以动态调整渲染帧率。 渲染帧率的下降,无疑会对耗电量、功耗、发热量产生积极影响。

多说一句,其实Adaptive Performance方案,我个人理解,也是通过:感知硬件状况,比如温度、功耗等等,然后通过调节渲染帧率、调节LOD水平,去达到一个动态的功能和功耗的平衡。就是三星那个项目,有着非常可观的性能和较低的功耗。

  • 5
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值