Announcement

Collapse
No announcement yet.

Your thoughts on and comments to Volume Rendering in Unreal Engine 4.

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

  • replied
    Originally posted by HowardM2020 View Post
    Hi Ryan, everyone, cheers for all the great tools and help!
    Can someone help me figure this out? I want to do a 16k image, with 1024 pixel tiles, 16x16, and it wont make a VT correctly.. its got gaps and lines, doesn't tile... in end even trying 512, 16x16 at 8k does not seem to work? (comes in at like 512x512x400) Are Volume Textures capped at 400x400 and thats why you did not list anything higher?
    Cheers!
    Depending on the engine release, you will need to change some .INI file to allow working with 8k size textures. You can find the correct .INI file and the specific setting to change at the UE4 Documentation pages. Since this setting exists since UE4.8, I am not sure it can be changed to 16k... in theory it could on newer engine releases past UE4.21, but I haven't tried myself.

    Leave a comment:


  • replied
    Hi Ryan, everyone, cheers for all the great tools and help!
    Can someone help me figure this out? I want to do a 16k image, with 1024 pixel tiles, 16x16, and it wont make a VT correctly.. its got gaps and lines, doesn't tile... in end even trying 512, 16x16 at 8k does not seem to work? (comes in at like 512x512x400) Are Volume Textures capped at 400x400 and thats why you did not list anything higher?
    Cheers!

    Leave a comment:


  • replied
    Originally posted by AnthonyStudio View Post
    Is the downloadable project working for 4.25? I can't get it to work, its just showing the default grids
    Hey man, not sure about the status on 4.25, but I am actually getting to work on the project this weekend.
    Release that works and is nice is coming next weekend at the latest. For real this time.

    Leave a comment:


  • replied
    Is the downloadable project working for 4.25? I can't get it to work, its just showing the default grids

    Leave a comment:


  • replied
    Originally posted by harry1511 View Post
    tommybazar how is yours progress with it so far?
    So, it only took me 3 months but I already got started on it
    I started making some changes to the structure of the plugin aside from just cleaning it up, so it will be more work than I expected.

    I'm hoping that the monsoon season finally starts here, so that I can keep working on this through the weekends without my friends constantly harassing me with going surfing and hiking and the like

    I'm pretty much done with the first part, which is a standalone plugin with functions for creating Volume Texture assets from .mhd and .raw files and some basic general utility functions. I'll polish it up and upload it next week.

    Then I will get started on the actual Raymarcher. It will be more work then I originally thought, because I've gotten some more experience working on our actual product and I intend to change the structure of the raymarched volume assets completely to make working with them really pleasant.

    It's coming, trust me (even though, like I said, I break promises).

    Cheers, Tommy.

    Leave a comment:


  • replied
    Update: I tested with HTC Vive, it works perfectly as expected! So I found a way to stream the packaged game from PC to Oculus Go instead of sideloading the project directly onto the headset. This is the only solution I can come with to have the content run on Oculus Go without suffering from heavy performance.

    tommybazar curious if you have figure a way to make this stuff work on mobile headset.

    Leave a comment:


  • replied
    RyanB you are right, I removed the scene depth, and it was still super choppy in Oculus Go. Maybe I should find another cheaper solution (if there is any out there) for mobile headsets. I will give it another try with HTC Vive next week though, and see...

    tommybazar how is yours progress with it so far?

    Leave a comment:


  • replied
    RyanB Thanks, I also thought the depth reading was the cause on android, but wasn't sure.

    Had another unrelated question - did you guys ever need to get VolumeTexture data back from the GPU onto the CPU?
    For example to save a volume that was painted at runtime.
    I see that all texture types (except for volume) have RHI functions to either lock the resource so you can read from it or to straight up read the data from them, but Volume Textures are like poor cousins, none of the regular utility functions exist on the RHI
    What we do now is - make slices out of volume texture and then get the data out of those. Obviously suboptimal, was wondering if there was a better way.

    Leave a comment:


  • replied
    oh, this won't work on android really because you cannot read scene depth. you'd probably have to remove all scene depth lookups from the box custom node and you would lose any sorting with opaque. could work if you dont care about that maybe. but still likely to melt a phone pretty quick.

    Leave a comment:


  • replied
    RyanB NilsonLima Thanks for the reply guys. However, I did change Primitive ID to GetPrimitiveData. The material does compile and work inside the editor. Problem is, it only fails to compile for Android...

    Leave a comment:


  • replied
    harry1511 Pretty much what Rayn B mentioned above. There is another custom node in the material called "Ray March Cube Setup" which is the Box Intersection function he is mentioning. There are 3 lines with Primitive.xxxx which needs to be fixed in order for the material to work.

    Leave a comment:


  • replied
    I removed that version of the material from the latest plugin. I don't have a copy here to look at, but if there is something broken with it, its probably the same old Primitive ID stuff that needs replacing.

    ie, there is a line similar to this near the top, you could try using this line (all primitive properties must be accessed this way now):


    float3 localcamvec = normalize( mul(Parameters.CameraVector, GetPrimitiveData(Parameters.PrimitiveId).WorldToLocal) ) * StepSize;

    A similar line needs changing in the Box Intersection function feeding the main raymarch.

    That IBL material just used a cubemap for lighting. The 2nd texture was a tiling noise with directional AO and shadowing prebaked in.

    I ended up not continuing that particular prototype because the new methods with SkyAtmosphere basically make it obsolete. See the volumetric cloud prototype under the Volumetrics plugin (available on github only so far) for an idea.

    Leave a comment:


  • replied
    Thanks for the quick reply,
    The code I mentioned above is actually from M_VolumeRayMarch_Lit_LinearSteps_IBL_ModTexture, so I guess Ryan's code uses 2 additional textures to get the image based lighting, and modulation effect (?) (which to be honest, I don't really need). But this IBL ray march material doesn't compile, and I wonder why. If you don't mind trying the code and see if it compiles for Android on your end, no worry if you don't really have time for it though, I know we are all busy

    For now, I will keep playing with it in your suggested direction, and see how things go. And look forward to your plugin too

    Thank you.

    Leave a comment:


  • replied
    Originally posted by harry1511 View Post
    I tested this material M_VolumeRayMarch_Lit_LinearSteps_FN, it complied fine, but is super heavy in Oculus Go.
    To be honest, I wouldn't expect anything else. Raymarching is hardcore for the GPU. It's an uphill battle to get it running decently on a RTX 2070 in VR on a PC.

    Just try multiplying these three things together to get the rough number of texture samples per frame!

    Number of pixels of the volume visible (worst case on the GO - 2560 x 1440 = ~4M)
    Number of raymarching steps (let's say a 100 to be conservative)
    I see you're using 2 textures with the possibility of a third if the sample is dense enough, so let's say 2.5.

    Looking at something close to literally a billion texture samples every frame.

    A good and easy first step is reducing the number of pixels. Since the volume texture you'll be using will usually be a lot less fine (something along the lines of 256^3 or something), it doesn't really need to be rendered at full resolution. Lucky for you, Unreal already has a pretty neat feature called "Separate Transluscency" that allows you to render materials on a separate buffer that doesn't have to be the same resolution as the regular viewport. So, try this for starters:

    In the material details, tick "Render after DOF" and "Mobile Separate Transluscency" (might need to put the material back into Transluscent, not sure).
    In your projects DefaultEngine.ini, set r.SeparateTranslucencyScreenPercentage to something low, such as 30.

    With 0.3 * 0.3 = 0.09 instead of 1*1 = 1, you're rendering ~11 times fewer pixels worth of raymarched material.
    11 times fewer raymarched pixels = 11 times fewer texture samples, while other stuff (such as text and lines) stays clear.
    And on the raymarched volume, the quality drop isn't too noticeable.

    Another way to get more performance out of this is using Volume Textures (instead of the pseudovolume textures), as Ryan's raymarcher code is old and UE now supports them natively.
    If you look a couple posts up, I was linking to my own plugin for that does that. Except right now it's hacky and ugly and overcomplicated, if you're not a coder, you'll not have a nice time working with it, honestly (and even if you are, it's not a pretty sight). Also it requires a custom engine build.

    I'll try making a clean, simple, minimal working example plugin for this later this week, so you non-coder guys can play with it too (ping me if it's not here by Sunday, as I'm a lazy slacker and break promises on a regular basis).

    Leave a comment:


  • replied
    tommybazar It seems the volume raymarch material I am using is not compiled for some reason. It is the M_VolumeRayMarch_Lit_LinearSteps_IBL_ModTexture from Ryan's plugin. The only I added in is the slide cut feature. I tested this material M_VolumeRayMarch_Lit_LinearSteps_FN, it complied fine, but is super heavy in Oculus Go.

    I tried your tip, but to be honest, I am clueless on how to edit these codes properly. Here is the current code btw:

    Code:
    float numFrames = XYFrames.x * XYFrames.y;
    float accumdist = 0;
    float curdensity = 0;
    float transmittance = 1;
    float3 localcamvec = normalize( mul(Parameters.CameraVector, GetPrimitiveData(Parameters.PrimitiveId).WorldToLocal) ) * StepSize;
    
    float3 invlightdir = 1 / LightVector;
    
    float shadowstepsize = 1 / ShadowSteps;
    LightVector *= shadowstepsize*0.5;
    ShadowDensity *= shadowstepsize;
    PreviewAmount *= StepSize;
    
    Density *= StepSize;
    float4 lightenergy = 0;
    
    int3 randpos = int3(Parameters.SvPosition.xy, View.StateFrameIndexMod8);
    float rand =float(Rand3DPCG16(randpos).x) / 0xffff;
    CurPos +=  localcamvec * rand.x * Jitter;
    
    
    for (int i = 0; i < MaxSteps; i++)
    {    
        if (CurPos.z >= SliceNr && CurPos.z <= SliceNr + SliceRange)
        {
            float3 volsample = PseudoVolumeTexture(Tex, TexSampler, saturate(CurPos), XYFrames, numFrames);
            float3 modsample = PseudoVolumeTexture(Tex3, TexSampler, ((CurPos+ModPanner)*ModulationTiling), 16, 256).rgb;
    
            float cursample = saturate(volsample.b + modsample.r * Modulation);
    
            //Sample Light Absorption and Scattering
            if( volsample.g + cursample > 0.001)
            {
    
                curdensity = 1 - exp(-cursample * Density);
    
                float4 lightingtemp = PseudoVolumeTexture(Tex2, TexSampler, saturate(CurPos), XYFrames, numFrames) * float4(SkyColor,1) * transmittance * curdensity;
                lightingtemp.xyz *= (modsample.g * ModGradient) + ModGradientOffset;
                lightingtemp.w *= (modsample.b * ModGradient) + ModGradientOffset;
                lightenergy += lightingtemp;        
                //lightenergy += modsample.g * ModGradient * transmittance * curdensity;
    
                lightenergy.xyz += volsample.g * transmittance * float3(0,1,0) * PreviewAmount;
    
                transmittance *= 1-curdensity;
    
            }
        }    
    
        CurPos -= localcamvec;
    }
    
    
    lightenergy.xyz += lightenergy.a * LightColor;
    
    return float4( lightenergy.xyz, transmittance);

    Leave a comment:

Working...
X