Announcement

Collapse
No announcement yet.

How to Sample SceneColorCopyTextureSampler using tex2Dlod in material Custom Node

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    How to Sample SceneColorCopyTextureSampler using tex2Dlod in material Custom Node

    Hi everyone.

    I am working on a not-realtime project in which i need to apply a very aggressive blur to a surface, requiring me to read from SceneColorCopyTexture

    The number of iterations mean i cannot use [UNROLL] on the loops, and there is divergent flow control in the shader, restricting me from using gradient operations such as Texture2DSample

    Normally the blur is done using the DecodeSceneColorForMaterialNode() function found in Common.ush but because that is using Texture2DSample it will not compile.

    I have tried inlining the function's content into the custom node (which normally works) and changing the Texture2DSample like from

    Code:
    Texture2DSample(SceneColorCopyTexture, SceneColorCopyTextureSampler, myUV);
    to:

    Code:
    tex2Dlod(SceneColorCopyTextureSampler, float4(myUV.xy, 0.0, 0.0));
    Whilst this compiles, it is not producing the same results.


    I have not used tex2Dlod before so I might be missing something, however I have a hunch this is actually being caused by the UE4 material compiler.

    If i debug a scene using the shader with Texture2DSample in RenderDoc, i can see the inputs include ScreenShadowMaskTexture (this appears to be what is being used as the SceneColor for this transluscent draw?), but when i run the shader with tex2Dlod this no longer appears as an input.

    Is there a possible way around this? Either to be able to access the scene texture with tex2Dlod, or to get around the restriction of using Texture2DSample in a very long looped shader?

    Any help much appreciated!

    #2
    Use Texture2DSampleLevel. Also, for huge blur you might want to consider two pass blur with separable kernel instead of sheer high number of samples.
    Last edited by Deathrey; 01-29-2019, 02:40 PM.

    Comment


      #3
      I don't think that there are mips generated for this texture.

      Comment

      Working...
      X