Announcement

Collapse
No announcement yet.

Experimentation: Volumetric Decals

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

    #16
    I have reported this as a bug but keep in mind that this feature is marked as Experimental and the engineer who wrote it is no longer here. We do not really use this feature for anything in any of our current games so it might not get prioritized any time soon.

    Generally, experimental means it works to play around with but it is not intended to be a shipping quality feature yet and multi platform support may be lacking.
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #17
      Originally posted by RyanB View Post
      I have reported this as a bug but keep in mind that this feature is marked as Experimental and the engineer who wrote it is no longer here. We do not really use this feature for anything in any of our current games so it might not get prioritized any time soon.

      Generally, experimental means it works to play around with but it is not intended to be a shipping quality feature yet and multi platform support may be lacking.
      Understood
      I just thought this was the answer to the other volumetric rendering thread.

      Visit my portfolio: jhgrace.com

      Comment


        #18
        It's been a while since anyone posted but wanted to share some progress I'd made using Volumetric Decals:

        Click image for larger version

Name:	HighresScreenshot00000.png
Views:	1
Size:	917.5 KB
ID:	1128396

        Click image for larger version

Name:	HighresScreenshot00001.png
Views:	1
Size:	835.4 KB
ID:	1128397

        Click image for larger version

Name:	HighresScreenshot00002.png
Views:	1
Size:	896.7 KB
ID:	1128398

        It's really killing my framerate though. I have 32 iterations in the Mandelbulb function as a maximum, and I can go down to 9-10 fps when really close to the volume, or inside it.

        Looking at some math optimizations to get rid of expensive operations, but anything else I could do?

        Was hoping Ryan might give some feedback on if there were any plans to improve/increase support for volumetric decals, or point me to where I might be able to improve it in the engine by editing source.

        Comment


          #19
          Optimizing volumetric functions is usually about getting the inner loop and the execution overheard to be a low as possible. That often seems to just require lots of experimentation to get right. If you post your shader code for it, it may be possible to optimize a bit. And it also may be easier to control how it performs using a regular material with the custom node. You may need to tweak the raymarching thresholds more aggressively etc.
          Ryan Brucks
          Principal Technical Artist, Epic Games

          Comment


            #20
            Hey Ryan,

            Thanks for responding!

            Here's the shader code:

            Code:
            // Spherical coordinate values
            float r = 0, theta = 0, phi = 0;
            int i = 0;
            
            float dr = 1.0;
            
            float3 ray = InputPosition + OriginOffset;
            
            //float m = dot(ray, ray);
            
            for(i = 0; i < MaxIterations; ++i)
            {
            // Optimization suggested by Inigo Quilez - commented as it causes issues right now
            /*
            m = dot(ray, ray);
            if(m > MaxDistance) 
            break;
            float m2 = m*m; float m4 = m2*m2;
            dr = Order * sqrt(m4 * m2 * m) * dr + 1.0;
            
            float x = ray.x; float x2 = x*x; float x4 = x2*x2;
            float y = ray.y; float y2 = y*y; float y4 = y2*y2;
            float z = ray.z; float z2 = z*z; float z4 = z2*z2;
            
            float k3 = x2 + z2;
            float k2 = rsqrt( k3*k3*k3*k3*k3*k3*k3 );
            float k1 = x4 + y4 + z4 - 6.0*y2*z2 - 6.0*x2*y2 + 2.0*z2*x2;
            float k4 = x2 - y2 + z2;
            
            ray.x = InputPosition.x + 64.0*x*y*z*(x2-z2)*k4*(x4-6.0*x2*z2+z4)*k1*k2;
            ray.y = InputPosition.y + -16.0*y2*k3*k4*k4 + k1*k1;
            ray.z = InputPosition.z + -8.0*y*k4*(x4*x4 - 28.0*x4*x2*z2 + 70.0*x4*z4 - 28.0*x2*z2*z4 + z4*z4)*k1*k2;
            */
            
            r = length(ray);
            if(r  > MaxDistance)
            	break;
            // Calculate spherical system coordinates
            theta = acos(ray.y/r);
            phi = atan2(ray.x, ray.z);
            dr = (pow(r, Order - 1.0) * Order * dr) + 1.0f;
            
            // Scale and restore the point
            float zr = pow(r, Order);
            theta = theta * Order;
            phi = phi * Order;
            
            // Convert back to cartesian coordinates
            ray = zr * float3(sin(theta) * sin(phi), cos(theta), cos(phi) * sin(theta));
            
            ray += InputPosition;
            
            }
            
            // Channel pack 
            // Result of distance estimator into Red 
            // Iteration count into Blue
            // Distance from ray start into Green
            return float3(0.5f * log(r) * r/dr, i, r);
            Here's the calling Material:

            Click image for larger version

Name:	Mandelbulb_material.png
Views:	1
Size:	219.5 KB
ID:	1128469

            Nothing too fancy going on here. I'll admit the intricacies of the math go over my head but it's a distance estimator function for a Mandelbulb volume.

            Code taken primarily from here: http://blog.hvidtfeldts.net/index.ph...actals-part-i/

            Inigo Quilez had an article where he posted a polynomial that could be used for avoiding the expensive trig operations for transcendental equation solving. That's probably what I'll do first when I get the code that's commented out to work.

            EDIT:

            Hey [MENTION=3692]RyanB[/MENTION] I threw in Inigo's optimizations but it didn't help any, I think they rely on the compiler folding the expressions or something, but that doesn't happen with custom nodes right?

            Anyway, kind of out of ideas right now, Googling for general material optimization tips, would appreciate any input you had.
            Last edited by Nightmask3; 05-28-2017, 04:30 PM. Reason: added info

            Comment


              #21
              Hey, sorry I haven't had time to look at this very closely yet.

              I still think I would probably move this all to a custom unlit material since who knows what exactly the volume decal code is doing. But here is some low hanging fruit.

              You use acos and atan2. You should try replacing with acosfast and atan2fast. See FastMath.usf for details. In most cases I have found, the fastmath functions work fine for volumetrics stuff but it can be hard to predict where precision issues show up.
              Ryan Brucks
              Principal Technical Artist, Epic Games

              Comment


                #22
                Hey [MENTION=3692]RyanB[/MENTION],

                No problem at all man! You're a tech artist at Epic so I'd imagine you're pretty busy. I'm happy for any time you can make for us on the forums here.

                Ohh so that was what you meant regarding a separate custom material! I was thinking that you meant a custom node in the Volume decal material, but was confused since that was what I was already doing.

                That makes a bunch of sense. I'd have to write the raymarching code again, but whatever at least I'd have more control over it that way!

                Also will replace those two functions. I think precision issues wouldn't be a problem cause I don't require super detailed results or anything. These are for gameplay usage (hopefully) and the player won't ever be looking too closely at them.

                I don't suppose there are any plans to expand Volume decal functionality? It's quite a cool piece of tech so I'd be interested to see more features added to it.

                Comment


                  #23
                  Unfortunately I do not think we have any plans to work on volume decals. They were just a free friday project by one of our engineers - Martin Mittring - who left epic late last year. So far we haven't found any practical 'shippable' uses of the volume decals in any products so there has not been much pressure internally to make them a fully supported feature. They are really fun to play with though. It is tricky since the shaders tend to be very expensive, and its easier to optimize these kinds of shaders on an individual basis when you have the full code per shader exposed.
                  Ryan Brucks
                  Principal Technical Artist, Epic Games

                  Comment


                    #24
                    Ah, shoot.

                    Ah well, they are a ton of fun to mess with, that's true. Could serve as a testbed for volumetric methods before you write the full custom node material for them.

                    In any case Ryan, thanks a bunch man. Will post with more updates soon, and hopefully with a video that runs at a decent framerate!

                    Comment


                      #25
                      on 4.18.3 nothing is showing up? does some settings change or do i need a different setup for the materials.or do i have to put some commands in to the console to make the volumetric decals work?

                      the Blend Mode need to be Translucent
                      and
                      There need to be and input for the normal (constant with z value 1 works fine)
                      Click image for larger version  Name:	Screenshot (345).png Views:	2 Size:	578.6 KB ID:	1444587
                      Last edited by DarknesZ; 03-16-2018, 06:48 AM.
                      my Artstation & YouTube Channel

                      Comment


                        #26
                        sorry to bump, but I also don't get anything to show up. whatever I try the volumetric decal is always fully invisible

                        I'm on 4.22
                        Last edited by Chosker; 08-06-2019, 05:52 PM.
                        Follow me on Twitter!
                        Developer of Elium - Prison Escape
                        Local Image-Based Lighting for UE4

                        Comment

                        Working...
                        X