Announcement

Collapse
No announcement yet.

So Blurred glass material is impossible in Unreal Engine 4?

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

    #91
    Can you test to put Blurriness parameter as constant. Because your loop iteration count is constant HLSL compiler will unroll the loop. If amount is constant then compile can pre calculate those expensive exp calls to your unrolled loop. Adding attribute
    Code:
    UNROLL
    directly before loop should add
    Code:
    [unroll]
    attribute on platforms where it's supported. Does that make it faster at all? If it does't then only choise is to try to reduce texture samples.

    Comment


      #92
      Unrolled loops, now there is 47-49 FPS (jumping for some reasons), but this is already a great success!
      Just checked if there is anywhere post process execution time... Maybe this:
      Click image for larger version

Name:	BlurShaderPerformance.png
Views:	1
Size:	131.8 KB
ID:	1100844
      And it's probably true, because I downed graphical settings from Epic to Low and now both blur passes takes around 1-1.5 ms, which is already pretty nice, including the fact, that there is 25 iterations.

      Comment


        #93
        Nice. After unrolling there isn't much that you can do. Now one iteration just calculates UV's(2xMAD) and blur with fallof.(2x3xMAD). So it's 8 ALU's and 2 TEX samples per iteration. So it's all about texture bandwith now.

        Comment


          #94
          I did not know about the unroll directive until now. Nice!

          Comment


            #95
            I'm using the example above as a blur in a post processing layer with blur offsets of around a thousand. It looks good even then, but I added a couple more samples in the corners to help avoid the horizontal and vertical streaking. Overall the effect only has about a 10% fps penalty. I also tried to handle the lighting variations. It's not perfect, but it's fairly stable for blur amounts between 2 and 1000.

            I also merged as many different statements as I could into one single execution line. Epic have said that there's a small speedup on the GPU from doing this.

            Code:
            float Cycles = 25;
            float c = 1.0f / (3.14159f * BlurAmount);
            float4 Blur = float4(0, 0, 0, 1);
            if (BlurAmount < 2) return SceneTextureLookup(UV, floor(BufferIndex), true);
            [unroll(Cycles)]
            for (int i = 0; i < Cycles; ++i) {
                float e = -(i * i) / (BlurAmount);
                float falloff = (c * exp(e));
                float e2 = -((i + 1) * (i + 1)) / (BlurAmount);
                float falloff2 = (c * exp(e2));
                float combinedFalloff = falloff + falloff2;
                float Offset = falloff2 / combinedFalloff;
            
            
                float2 UVOffset = PixelSize * (i + Offset);
                Blur += 
                    (SceneTextureLookup(UV + float2(UVOffset.x, 0), BufferIndex, true)
                    + SceneTextureLookup(UV + float2(0, UVOffset.y), BufferIndex, true)
                    + SceneTextureLookup(UV + float2(UVOffset.x, UVOffset.y), BufferIndex, true)
                    + SceneTextureLookup(UV + float2(UVOffset.x, -UVOffset.y), BufferIndex, true)) * combinedFalloff;
            }
            return (Blur * clamp(13 - BlurAmount, 2, 12) * BlurAmount) / (32 + BlurAmount / Cycles);


            Last edited by Antidamage; 02-21-2016, 07:33 AM.

            Comment


              #96
              I am very much interested in your video tutorials for setting custom blur glass materials. Thank you.

              Comment


                #97
                Originally posted by Antidamage View Post

                Code:
                float Cycles = 25;
                float c = 1.0f / (3.14159f * BlurAmount);
                float4 Blur = float4(0, 0, 0, 1);
                if (BlurAmount < 2) return SceneTextureLookup(UV, floor(BufferIndex), true);
                [unroll(Cycles)]
                for (int i = 0; i < Cycles; ++i) {
                    float e = -(i * i) / (BlurAmount);
                    float falloff = (c * exp(e));
                    float e2 = -((i + 1) * (i + 1)) / (BlurAmount);
                    float falloff2 = (c * exp(e2));
                    float combinedFalloff = falloff + falloff2;
                    float Offset = falloff2 / combinedFalloff;
                
                
                    float2 UVOffset = PixelSize * (i + Offset);
                    Blur += 
                        (SceneTextureLookup(UV + float2(UVOffset.x, 0), BufferIndex, true)
                        + SceneTextureLookup(UV + float2(0, UVOffset.y), BufferIndex, true)
                        + SceneTextureLookup(UV + float2(UVOffset.x, UVOffset.y), BufferIndex, true)
                        + SceneTextureLookup(UV + float2(UVOffset.x, -UVOffset.y), BufferIndex, true)) * combinedFalloff;
                }
                return (Blur * clamp(13 - BlurAmount, 2, 12) * BlurAmount) / (32 + BlurAmount / Cycles);
                Hey everyone!
                So i'm trying to use this code with a material exactly like you pictured (had no luck putting it into material function, it complains about SceneTexture node). And what i get as a result is that editor crashes when i enter post process volume with this mat assigned. Can anyone help?

                Comment


                  #98
                  Bump for greater justice! We need blurred/privacy glass solution!

                  Comment


                    #99
                    Originally posted by Filly_The_Owl View Post
                    We need blurred/privacy glass solution!
                    Just wear pants

                    Comment


                      Is there a youtube tutorial where this is explained?

                      Cheers.

                      Comment


                        Wish this was easier to achieve or maybe an updated tutorial of some sort.

                        Comment


                          Originally posted by jamesoloughlin View Post
                          Wish this was easier to achieve or maybe an updated tutorial of some sort.
                          4.16 includes the Background Blur UMG widget feature. Just add it to a widget and set the amount of blur.

                          The post here has become obsolete.
                          LEGENDS OF EPICA | CS - SPACE ALPHA

                          Comment


                            Originally posted by unit23 View Post
                            4.16 includes the Background Blur UMG widget feature. Just add it to a widget and set the amount of blur.

                            The post here has become obsolete.
                            unit23. I’ll look into. Thanks for helping an Unreal newbie.

                            Comment


                              I tried using background blur on a 3D widget as a substitute to a material option but no dice. Background blur doesn’t work on 3D widgets.

                              Comment


                                Originally posted by unit23 View Post
                                4.16 includes the Background Blur UMG widget feature. Just add it to a widget and set the amount of blur.

                                The post here has become obsolete.
                                Hardly. I still learned a lot from this and if you need to blur within a material (not with a material applied in the world) then this helps a lot.
                                http://unrealdeveloper.uk

                                Comment

                                Working...
                                X