Home Unreal Engine

How would you go about implimenting this into UDK?

ngon master
Offline / Send Message
almighty_gir ngon master
so i'm working on trying to emulate as much of the UE4 tech paper that was released a little while back.

http://www.unrealengine.com/files/downloads/2013SiggraphPresentationsNotes.pdf

so far i've gotten the BRDF working, it's really nice, and it works with cubemap blurring. i'll be making a bunch of custom/pre-filtered cubemaps to go with it soon. but in the mean time the biggest thing that's missing is the image based lighting to go with it.

the biggest issue i'm having, is the way it samples the cubemap texture. it uses something called "hammersley" as one of its values. i did some research and i found what that is.

it's a numeric pattern to generate sampling points on a hemisphere. it also generates matching coordinates in 2d.

http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html#sec-PointsOnSphere

i am quite literally tearing my hair out trying to get that value working in udk. once i have it working, *vadervoice* the circle is complete.

Replies

  • r4ptur3
    Options
    Offline / Send Message
    r4ptur3 polycounter lvl 10
    I don't know how to do this, but i'd give you my right arm for it!!
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Mathematical construct issues aside, I've never, ever, had a piece of HLSL with a FOR loop work in a UDK custom node.
    Regardless of if it was fed a constant or variable for number of loops.
    This pretty well precludes the entire importance sample and gather functions and rather destroys the idea of implementing that in identical fashion within the existing UDK framework. :(

    Best thing I can recommend within UDK's present limits is to either use one or more pre-blurred cubemaps and interpolate between them based on your roughness, or use one of the cubemap blurring routines that have shown up here on Polycount.

    My method (basic node based, non mipmap reliant)
    DrAlex789's method. (custom node based, mip-reliant)
  • almighty_gir
    Options
    Offline / Send Message
    almighty_gir ngon master
    cheers Vailias, if you can't do it, i don't think anyone can haha.

    and i was already using one of those methods :)

    thanks!
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Welcome. And thanks for the complement. :)
    Sorry its not a "here's how to do it" solution. If we COULD utilize a for loop we'd have so many nice effects possible. (of course we'd have lots of crashy shaders along the way too.. loop constructs can be problematic)

    Also from the looks of things I'd go with DrAlex's method. It looks to be cheaper since its a MIP lookup rather than an analytic blur.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    This stuck with me. After some further, more detailed, reading and researching, you can totally create the van der Corput sequence that Hammersly and Halton based extended from in UDK. You'll need DX11 mode on to have it work, as that supports Shader Model 4 and therefore the bitwise operators that make the sequence fairly easy to create.
     float radicalInverse_VdC(uint bits) {
         bits = (bits << 16u) | (bits >> 16u);
         bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
         bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
         bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
         bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
         return float(bits) * 2.3283064365386963e-10; // / 0x100000000
     }
    //The ith point xi is then computed by
    
    
     vec2 hammersley2d(uint i, uint N) {
         return vec2(float(i)/float(N), radicalInverse_VdC(i));
     }
    
    

    If you convert that first function to a udk custom node, then the second function as either its own custom node or an equivalent set of UDK nodes you'll have what you need to calculate the points to sample from.
    To get the domain to pick from, just use a texcoord node and turn it into a stepped gradient.
    N = Number of points
    i = (floor(TexCoods*N)).x //just the X (or Red) channel from the texcoords. 
    
    you can then plug (i) into the radicalInverse function as above to get the Y(orGreen) value for the point to sample. X coord is i/N. Put them together with an append vector node.

    Now as far as where to go from here.. I'm running into a bit of a mental brick wall. Don't have UDK accessible at the moment to do actual testing.
  • almighty_gir
    Options
    Offline / Send Message
    almighty_gir ngon master
    hey man, if you want to add me to skype, either Almighty.gir, or lee_devonald@crazyferretstudios.com will work.

    maybe we can work together on getting this in. =]
Sign In or Register to comment.