【目标】

MaterialLOD QualitySwitch

【思路】

1 QualitySwitch

UE4有三挡

UE3


2 现在UE3需要添加三挡

3

UE3

class UMaterialExpressionQualitySwitch : public UMaterialExpression
{
public:
    //## BEGIN PROPS MaterialExpressionQualitySwitch
    FExpressionInput High;
    FExpressionInput Low;

4

【步骤】

1 修改UMaterialExpressionQualitySwitch 

\ue3\Development\Src\Engine\Classes\MaterialExpressionQualitySwitch.uc

var ExpressionInput High;
var ExpressionInput Mid;
var ExpressionInput Low;

2 修改EMaterialShaderQuality 添加中级

enum EMaterialShaderQuality
{
    MSQ_HIGH                =0,
    MSQ_MID                    =1,
    MSQ_LOW                 =2,
    MSQ_MAX                 =3,
    // Terrain only supports high quality
    MSQ_TERRAIN                =MSQ_HIGH,
    // Use an invalid value for default value to functions when not specifying a quality
    MSQ_UNSPECIFIED            =MSQ_MAX,
};

3 修改\ue3\Development\Src\Engine\Classes\Material.uc

var const native duplicatetransient pointer MaterialResources[3]{FMaterialResource};

修改UMaterial.MaterialResources 相关的

4 UMaterial.Serialize中有序列化的东西

还是要添加个版本号

EUnrealEngineObjectVersion

    // - Add MaterialShaderQuality Mid
    VER_UNIFORM_EXPRESSIONS_IN_SHADER_CACHE                = 872,

UMaterial.Serialize

            if (
                QualityIndex < 2 ||                    // MaterialResources's old size is 2
                (QualityIndex >=2 && Ar.Ver() >= VER_ADD_EXPRESSIONS_SHADERQUALITY_MID) 
                ) 
            {
                // Serialize the material resource.
                MaterialResources[QualityIndex]->Serialize(Ar);
                if (Ar.Ver() < VER_UNIFORM_EXPRESSIONS_IN_SHADER_CACHE)
                {
                    // If we are loading a material resource saved before texture references were managed by the material resource,
                    // Pass the legacy texture references to the material resource.
                    MaterialResources[QualityIndex]->AddLegacyTextures(ReferencedTextures_DEPRECATED);
                    // Empty legacy texture references on load
                    ReferencedTextures_DEPRECATED.Empty();
                }            
            }

4 修改MSQ_MAX  相关的

UMaterialInstance.StaticPermutationResources

UMaterialInstance.StaticParameters

\ue3\Development\Src\Engine\Classes\MaterialInstance.uc 改成3个

/**
* The set of static parameters that this instance will be compiled with.
* This is indexed by EMaterialShaderPlatform.
* Only the first entry is ever used now that SM2 is no longer supported,
* But the member is kept as an array to make adding future material platforms easier.
* The second entry is to work around the script compile error from having an array with one element.
*/
var const native duplicatetransient pointer StaticParameters[3]{FStaticParameterSet};
/**
* The material resources for this instance.
* This is indexed by EMaterialShaderPlatform.
* Only the first entry is ever used now that SM2 is no longer supported,
* But the member is kept as an array to make adding future material platforms easier.
* The second entry is to work around the script compile error from having an array with one element.
*/
var const native duplicatetransient pointer StaticPermutationResources[3]{FMaterialResource};

上面直接改uc数组大小的方式 貌似会有问题,序列化会出问题

make报错

手动改h文件 编译exe 再修改uc,make

5 修改FSystemSettings.bAllowHighQualityMaterials 相关

添加一个新的成员

    /** Materials Quality Level    */
    INT        QualityMaterialsLevel;

     /** Materials Quality Level    */
    { SST_INT, SSI_SCALABILITY, TEXT( "QualityMaterialsLevel" ), &GSystemSettings.QualityMaterialsLevel, &VSSMaterilQuality, TEXT( "Materials Quality Level." ) },

FSystemSettings.ApplySettings

    // Reattach components if world-detail settings have changed.
    if( OldSystemSettings.DetailMode != DetailMode || 
        OldSystemSettings.bAllowHighQualityMaterials != bAllowHighQualityMaterials ||
        OldSystemSettings.QualityMaterialsLevel != QualityMaterialsLevel)
    {

在BaseSystemSettings.ini配置

QualityMaterialsLevel=0

ExampleSystemSettings.ini同理

6 UMaterialInterface.GetDesiredQualityLevel 

        Quality = GSystemSettings.bAllowHighQualityMaterials ? MSQ_HIGH : MSQ_LOW;

改为

         Quality = EMaterialShaderQuality(GSystemSettings.QualityMaterialsLevel);

FMaterial.CacheShaders

    if (Quality == MSQ_UNSPECIFIED)
    {
        Quality = GSystemSettings.bAllowHighQualityMaterials ? MSQ_HIGH : MSQ_LOW;
    }

改为

     if (Quality == MSQ_UNSPECIFIED)
    {
        Quality = EMaterialShaderQuality(GSystemSettings.QualityMaterialsLevel);
    }

7 修改Material切换按钮响应

void WxEditorFrame::MenuMaterialQualityToggle( wxCommandEvent& In )
{
    // to be safe, we wait until rendering thread is complete
    FlushRenderingCommands();
    // toggle the system setting, mimicing what the console command does - it would be nice
    // if system settings had a function interface instead of console commands
//    GSystemSettings.bAllowHighQualityMaterials ^= 1;
    
    GSystemSettings.QualityMaterialsLevel ++;
    if (GSystemSettings.QualityMaterialsLevel >= EMaterialShaderQuality::MSQ_MAX)
        GSystemSettings.QualityMaterialsLevel = EMaterialShaderQuality::MSQ_HIGH;


8 显示出Quality值到编辑器

WxMaterialEditorBase.DrawMaterialInfoStrings.

        FLinkedObjDrawUtils::DrawShadowedString(
            Canvas,
            5,
            DrawPositionY,
            *FString::Printf(TEXT("Quality[%d] DrawCall: %d Instructions: %d DrawTime:%.6f ms"),
            GSystemSettings.QualityMaterialsLevel,
            PreviewMeshComponent->LastDrawCalls,PreviewMeshComponent->GetUsedMaterialsInstructionCounts(),PreviewMeshComponent->LastDrawTimes),
            FontToUse,
            FLinearColor(0.8,1,1)
            );

9

scale set QualityMaterialsLevel 0-2

【运行】

"/cgi-bin/micromsg-bin/auth";
"/cgi-bin/micromsg-bin/sendmsg";
"/cgi-bin/micromsg-bin/sync";
"/cgi-bin/micromsg-bin/uploadmsgimg";
"/cgi-bin/micromsg-bin/getmsgimg";
"/cgi-bin/micromsg-bin/init";
"/cgi-bin/micromsg-bin/getupdatepack";
"/cgi-bin/micromsg-bin/searchfriend";
"/cgi-bin/micromsg-bin/getinvitefriend";


3


16101301(MaterialLOD QualitySwitch)的更多相关文章

  1. git-简单流程(学习笔记)

    这是阅读廖雪峰的官方网站的笔记,用于自己以后回看 1.进入项目文件夹 初始化一个Git仓库,使用git init命令. 添加文件到Git仓库,分两步: 第一步,使用命令git add <file ...

  2. 读书笔记:JavaScript DOM 编程艺术(第二版)

    读完还是能学到很多的基础知识,这里记录下,方便回顾与及时查阅. 内容也有自己的一些补充. JavaScript DOM 编程艺术(第二版) 1.JavaScript简史 JavaScript由Nets ...

  3. Recurrent Neural Network系列1--RNN(循环神经网络)概述

    作者:zhbzz2007 出处:http://www.cnblogs.com/zhbzz2007 欢迎转载,也请保留这段声明.谢谢! 本文翻译自 RECURRENT NEURAL NETWORKS T ...

  4. 谈谈一些有趣的CSS题目(十二)-- 你该知道的字体 font-family

    开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...

  5. RxJS + Redux + React = Amazing!(译一)

    今天,我将Youtube上的<RxJS + Redux + React = Amazing!>翻译(+机译)了下来,以供国内的同学学习,英文听力好的同学可以直接看原版视频: https:/ ...

  6. ASP.NET Core 中文文档 第四章 MVC(3.8)视图中的依赖注入

    原文:Dependency injection into views 作者:Steve Smith 翻译:姚阿勇(Dr.Yao) 校对:孟帅洋(书缘) ASP.NET Core 支持在视图中使用 依赖 ...

  7. 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)

    从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://w ...

  8. 恢复SQL Server被误删除的数据(再扩展)

    恢复SQL Server被误删除的数据(再扩展) 大家对本人之前的文章<恢复SQL Server被误删除的数据> 反应非常热烈,但是文章里的存储过程不能实现对备份出来的日志备份里所删数据的 ...

  9. 浅谈WEB页面提速(前端向)

    记得面试现在这份工作的时候,一位领导语重心长地谈道——当今的世界是互联网的世界,IT企业之间的竞争是很激烈的,如果一个网页的加载和显示速度,相比别人的站点页面有那么0.1秒的提升,那也是很大的一个成就 ...

随机推荐

  1. AWK命令学习

    使用方法 awk 'pattern {action}' {filenames} 尽管操作可能会很复杂,但语法总是这样,其中 pattern 表示 AWK 在数据中查找的内容,而 action 是在找到 ...

  2. jQuery validation学习(1)验证只输入空格通过验证

    当input输入了空格是不会提示信息的 一般会去除空格然后进行验证 这个时候就要添加onkeyup事件去除左侧的空格 验证只输入空格通过验证 //添加验证手机方法 jQuery.validator.a ...

  3. cocos2dx && Lua 环境配置

    需要的材料: 1.vs2013 2.python-2.7.3(2.7.x高于2.7的版本可能会出现错误) 3.Sublime Text 2(破解的) 4.cocos2dx-3.2 步骤: 1.安装vs ...

  4. hibernate联合主键 注解方式

    转载自https://my.oschina.net/yotoo/blog/265571 方法一:主键类用@Embeddable,pojo类仍然用@Entity但是引用主键类的对象用@Id 主键pojo ...

  5. 3.密码pasuwado————记第一次超越Candy?

    激动人心的2016.11.4模拟赛结束了 更激动人心的是我得了90分,第一次超越豪哥,特立文纪念. 3.密码 [问题描述] 哪里有压迫,哪里就有反抗. moreD的宠物在法庭的帮助下终于反抗了.作为一 ...

  6. LINUX安全加固规范

    1 概述 近几年来Internet变得更加不安全了.网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏.截取和修改的风险也在增加. 只要有值得偷窃的东西就会有想办法窃取它的人 ...

  7. 关于editor网页编辑器ueditor.config.js 配置图片上传

    最近公司项目在做一个门户网站,其中新闻和简介等部分使用到了ueditor编辑器,但是上级明确指示需要图片上传这个功能,这时却发现图片上传功能不能正常使用,上传时一直报错,网上收了好几个处理办法,都说的 ...

  8. 命令行用sublime打开当前目录

    执行    ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" subl 就可以在命令行用 ...

  9. java subList方法小记

    在java中,我们有时候需要对一个list进行拆分处理,这个时候就需要用到list的切割方法subList. 我们知道list里面的序号起始是从0开始的,所以一个含有23条数据的list,它的序号是从 ...

  10. C语言习题(结构)

    实际应用中经常会用到二维平面上的点,点的操作包括设置点的位置( pointT setPoint(double x , double y ) ),显示第n个点的位置( void showPoint(po ...