【目标】

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. Windows光标形状

    ::SetCursor( LoadCursor(NULL, IDC_XXX) ); IDC_ARROW (plain) IDC_HELP (arrow + question mark) IDC_APP ...

  2. WebForm Application Viewstate 以及分页(功能性的知识点)

    Application: 全局公共变量组 存放位置:服务器 特点:所有访问用户都是访问同一个变量,但只要服务器不停机,变量一直存在于服务器的内存中,不要使用循环大量的创建Application对象,可 ...

  3. 【Splay】bzoj3223-Tyvj1729文艺平衡树

    一.题目 Description 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 ...

  4. Angular.js 的初步认识

    MVC模式 模型(model)-视图(view)-控制器(controller) Angular.js采用了MVC设计模式的开源js框架 1.如何在angular.js建立自己的模块(model),控 ...

  5. hihoCoder太阁最新面经算法竞赛19

    比赛链接:http://hihocoder.com/contest/hihointerview28/problems A. 固定一个方向,两两相邻的点顺时针或逆时针构造三个向量,判断这个点在这个向量的 ...

  6. 关于phpcms 万一忘记密码怎么破?

    莫慌~海洋小生教你~我也是偷偷学来的,呀哈哈哈! first:............................你就认命吧!哈哈哈... 开玩笑开玩笑! LOOK HERE ↓: 1.在没有安装 ...

  7. SQL 已有数据的表创建标识列

    针对已有数据的表创建标识列: ,) constraint FID_1 primary key(FID)

  8. kali4.0 安装32位库

    一.前情提要: OS:Kali4.0 64bit 二.安装32位库: 错误方法:sudo apt-get install lib6-i386 正确方法如下: 1.先以root用户身份登陆: su ro ...

  9. C++Primer 5th 练习 12.19

    这阵子真是太忙了, 连续做了四个课设. 当然这并不能作为好久没写博客的借口, 没写博客的主要原因只有一个: 懒. 最近又开始回顾C++的语法与特性(据说C++就是一门需要反复回顾的语言),以及学习C+ ...

  10. angularjs指令系统系列课程(2):优先级priority,模板template,模板页templateUrl

    今天我们先对 priority,template,templateUrl进行学习 1.priority 可取值:int 作用:优先级 一般priority默认为0,数值越大,优先级越高.当一个dom元 ...