Unity LWRP 学习之 RenderFeature

RenderFeature是一种扩展LWRP的方法。该方法还是实验版。

实现管道的参数的定制,其好处就是不需要修改物体的Shader,比如要实现一个如下图的显示隐藏背后的轮廓的需求。

通常是需要修改对应的Shader的,使用两个Pass进行绘制,一个画正面,一个画轮廓,正面使用正常的Pass就可以,轮廓需要关闭Depth Test设置。

如果有RenderFeature,或者SRP,那就不需要去修改物体的Shader了。定义一个共通的轮廓的Shader Pass就可以了。

环境:Unity 2019.1.4

LWRP版本:5.16.1(试验版)

5.7.2中还没有加入其功能。

可以通过以下设置进行管道的参考的定制。

自定义RenderObjects类

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


public class CustomRenderObject : RenderObjects
{

}

使用一两个Cube,定义红Cube的Layer为UI

看下面的的设置过程,先在DefaultLayer Mask中删除UI,表示先不进行UI Layer的渲染。

Features的设置的对标准管线进行Override,这里Layer Mask配置的UI Layer

可以看到这里的设置是Depth Test设置为Greater,表示如果Depth大于其才进行显示,

其中Materail可以配置为轮廓的Shader。这里只是随便找了一个。

效果如下:

以下是在使Custom Forward Render生效

目前总体来看,LWRP的很多文档,还不是很全,还需要有一定的爬坑的过程啊。

汇总一些 相关的资料
● Scriptable Render Pipeline: github.com/Unity-Technologies/ScriptableRenderPipeline
● LWRP 4.0.1 Forum Release Notes: forum.unity.com/threads/lwrp-4-0-1-preview-is-out.562291/
● LWRP Shader Differences Guide: github.com/johnsietsma/ExtendingLWRP/wiki/Shaders
● Custom Render Pipeline Tutorial: catlikecoding.com/unity/tutorials/scriptable-render-pipeline/

● Boat Attack Demo: github.com/Verasl/BoatAttack/
● Extending LWRP: Blurry Refractions Example: https://github.com/Unity-Technologies/LWRP-CustomRendererExamples
● Trash Dash - LWRP Version: github.com/Unity-Technologies/EndlessRunnerSampleGame

发布了51 篇原创文章 · 获赞 10 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/FeiBin2013/article/details/91832304
今日推荐