欢迎光临散文网 会员登陆 & 注册

UE5.1_Niagara高级1.1 _Simulation Stage Fill Render Target

2023-03-29 09:42 作者:Winter惜曦  | 我要投稿
  • Enable Simulation Stages on a GPU emitter by checking "Enable Simulation Stages" in advanced emitter properties

    【通过勾选发射器属性里的高级里的“Enable Simulation Stages”来给GPU发射器启动模拟阶段(UE5.1更新为:点击“+Stage”,选择Generic Simulation Stage来添加模拟阶段)】

  • Think of a simulation stage as an additional "stack" like Particle Update. The difference is it can iterate, meaning run multiple times on a single frame across all the elements in it.Think of it like a "For Loop" in the stack.

    It is also unique because its "Iteration source" can be more than just particles. A Simulation Stage can iterate over every grid cell in a Grid 2d collection to create solvers, iterate over every pixel in a render target to write to it, or iterate over every particle.

    【可以把模拟阶段看作是另外的像粒子更新这样的堆叠。区别是它可以迭代,意味着可以在单一帧中对所有元素重复运行多次。可以看作在堆叠里循环】

    【它也是独特的,因为它的“迭代源”不只可以是粒子。一个模拟阶段可迭代在2d网格集合中的每个网格单元格来创造结算器,可迭代在一个渲染目标的每个像素来写入,或迭代在每个粒子】

  • Up at the emitter level, we initialize a Render Target, and a Texture Sample.

    【在发射器层级,我们初始化一个渲染目标,和一个纹理采样】

  • We set some emitter level variables for sprite properties, because our sprite renderer source mode is set to emitter, meaning our simulation contains no particles.

    【我们设置一些发射器层级的变量作为图片属性,因为我们图片渲染器来源模式设为发射器,意味着我们模拟不包含粒子】

  • On the simulation stage settings, we choose the render target as our iteration source. this means the stage will iterate over every texel and perform work on  it directly

    【在模拟阶段设置中,我们选择渲染目标作为我们的迭代源。这意味着阶段会迭代在每个纹素并直接作用于它】

  • In the simulation stage itself, we create a UV by dividing the index of the iteration source (in this case, each texel of our render target) by the size of the target. We use that to sample the texture, and then call a function to fill the render target directly. Note that in this context, Exec Index means the iteration source element, i.e. a render target cell, grid 2d cell, etc.

    【在模拟阶段本身,我们通过用渲染目标的大小除迭代源(在此示例,我们渲染目标的每个纹素)的索引创建一个UV(即:迭代源索引÷渲染目标大小)。我们使用它来采样纹理,然后使用函数直接填充渲染目标。注意这里的语境,Execution Index指的是迭代源元素,如:一个渲染目标单元格,网格2d单元格等】

  • Lastly, we need to make a texture object parameter in our assigned sprite material and name it. In this case, it is named "Fill RT".

    On the sprite renderer, we add an entry to the "material parameter bindings" array and pick that named parameter, and assign the render target. Now the system passes the filled render target directly to the sprite renderer.

    【最后,我们需要制作纹理目标参数到我们使用的的图片材质并命名它。在这示例,它叫“Fill RT”。】

    【在图片渲染器,我们添加一个入口到“material parameter bindings”数组并选中命名参数,和绑定渲染目标。现在系统直接传递填充的渲染目标到图片渲染器中】

  • Texture Sample【纹理采样】变量:对纹理进行采样的数据接口

  • Render Target 2D【渲染目标2D】变量:渲染目标2D的数据接口

  • Simulation Stage【模拟阶段】:数据流位置处于粒子更新与渲染之间

  • Generic Simulation Stage Settings【生成模拟阶段设置】

    Enable Binding【启动捆绑】

    Num Iterations【迭代数量】

    Num Iterations Binding【迭代数量捆绑】

    Iteration Source【迭代源】:即对哪类数据进行迭代运算,来源提供如元素数量和堆叠环境变量等

    Particle【粒子】

    Data Interface【数据接口】

    (仅Particle)Particle Iteration State Enable【粒子迭代状态启动】

    (仅Data Interface)Data Interface【数据接口】

    (仅Data Interface)Execute Behavior【执行行为】:控制什么时候模拟阶段应该执行

    Simulation Stage Name【模拟阶段名字】

    Override GPU Dispatch Type【重置GPU发送类型】

  • Cus_SampleTextureToRenderTarget2D模组

    Render Target 2D→Set Render Target Value节点

    IndexX【设置元素的X索引】

    IndexY【设置元素的Y索引】

    Value【设置数值】

    Texture Sample→Sample Texture 2D节点

    UV【纹理坐标】

    Execution Index节点:当前执行的索引号,此处为迭代源的元素的线性索引号

    Render Target 2D→Linear to Index节点

    Linear【线性的】:输入元素的线性索引号,从而获得元素在矩阵中的X/Y的索引号

    Render Target 2D→Get Render Target Size节点:获得矩阵的Width(X)和Height(Y)的长度

    Convert节点:将输入类型转换为想要的输出类型,如:将两个数转换成一个Vector2D

    Add节点:矩阵坐标Vector2D的X和Y都加0.5,使采样点居中偏移

    Divide节点:矩阵坐标Vector2D除以矩阵的宽高Vector2D,从而获得元素在矩阵中标准化的位置,作为UV


UE5.1_Niagara高级1.1 _Simulation Stage Fill Render Target的评论 (共 条)

分享到微博请遵守国家法律