Dynamic blob shadow ?

I’ve been working a lot with movable characters lately, and while the feature to have capsule shadows is very nice, it is unfortunately more or less unusable in the majority of cases. For instance, most my characters get half their head lit up, and the rest goes completely black. I have the correct physics assets, but it looks really bad. Maybe you could add a slider to adjust the amount of shadow that is added or something simiilar, unless it’s possible to get better quality.

Btw, Showdown has blob shadows. Would those be mobile VR friendly?

The material will not be very expensive, but as with everything it depends on your overall scene budget and what you have room to render. If your scene is already very expensive then you may have to make room. Use profilegpu before and after adding these effects to gauge effect.

I guess what I wanted to ask if Showdown’s blob shadows are essentially the same as Unity’s Shadowrun blob shadows (same look, as cheap performance wise).

Scene budget is 60 drawcalls and 100k tris (Oculus never specified, but I assume it’s in the view, not the whole level).

I’m not really in a position to comment on anything unity related. I’ve never even seen the unity editor.

With 60 draw calls you will have to choose your draw calls carefully. If you need to draw lots of blob shadows you could perhaps batch them and use vertex shader to map them to individual characters or something like that to use less draw calls. You would basically use vertex color or some other bakeable attribute to select which ones go where.

I’ve made something like this for Chasing Robbers:

https://i.imgsafe.org/a428e33.png

and result:

https://i.imgsafe.org/150c959.png

So, I finally got to the point where I have characters (simple animated actors) in my scene, and I loaded up Showdown demo to see how it’s made. For once, there are no bipedal characters. So the only show that was there was from the big bad robot. It’s the engine’s sphere with blob textures on it and some really weird spaghetti material setup :frowning: It certainly doesn’t look like Shadowgun’s blob shadow at all :confused:

They used this Inigo Quilez :: computer graphics, mathematics, shaders, fractals, demoscene and more

Care to elaborate how to replicate all that in UE4 and yet have it working super fast on mobile? (I also sent you a PM :wink: )

You could just copy/paste shader toy sphere occlusion function to custom node. Shader - Shadertoy BETA



// Sphere occlusion
float sphOcclusion( in vec3 pos, in vec3 nor, in vec4 sph )
{
    vec3  di = sph.xyz - pos;
    float l  = length(di);
    float nl = dot(nor,di/l);
    float h  = l/sph.w;
    float h2 = h*h;
    float k2 = 1.0 - h2*nl*nl;

    // above/below horizon: Quilez - http://iquilezles.org/www/articles/sphereao/sphereao.htm
    float res = max(0.0,nl)/h2;
    // intersecting horizon: Lagarde/de Rousiers - http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
    if( k2 > 0.0 ) 
    {
        #if 1
            res = nl*acos(-nl*sqrt( (h2-1.0)/(1.0-nl*nl) )) - sqrt(k2*(h2-1.0));
            res = res/h2 + atan( sqrt(k2/(h2-1.0)));
            res /= 3.141593;
        #else
            // cheap approximation: Quilez
            res = pow( clamp(0.5*(nl*h+1.0)/h2,0.0,1.0), 1.5 );
        #endif
    }

    return res;
}


@Kalle_H: So, I would make a sphere, attach it to the character’s feet bones and origin bone, and apply that custom node material and be done ?

Pretty much yes.

I copied/pasted the code into the custom node. It worked, showed preview when custom node was selected. However, when I plug custom node into material, anywhere, I get errors. Something about unexpected token ‘(’

Do you know what’s happening by chance and how can i get it working?

Thanks!

Bumpy bump!

@: any thoughts about this custom shader for “sphere AO” ? Thanks.

Hi,

The Sphere_AO material function returns a fraction that tells you the fraction of occlusion for a given position in the world that is given by a sphere of a given size and location.

Put another way, its asking "How much does this Sphere occlude the Sky (or hemisphere). "

To use it on a flat blob shadow card you can simply plug in the location of your character and the sphere radius (or one per each leg etc). Because its a blob shadow you will have to balance between having the correct location and correct radius. Generally, using the Sphere_AO function you may want to boost the occlusion by either over estimating your sphere size or by applying a pow to the output perhaps if this is for a stylized game.

A more advanced/accurate way to use it on translucency is to use the “WorldPosition Behind Translucency” input as the position. I just look at the function though and for some reason I did not expose the Position as an input which is a pretty unfortunate oversight. If you go inside you can replace the “Absolute World Position” input with something else and use that and it will work. Or you could make it a material function and sample it on the ground of your environment but that wouldn’t be my first choice, doing is using translucency would be more reuable.

Ouch, sounds complicated :confused: I was hoping to add the code from above to a custom node, plug it into material node, apply material to a low poly sphere attached to each leg of the character (and hidden in-game) O.o

It’s really just to ground characters in the scene when they are near player. It doesn’t have to be be accurate at all, nor resemble character’s shape. It should be similar to Showdown VR blob shadows, but demo doesn’t have any characters in it, except the robot and its blob shadow materials looks like a bowl of Pad Thai - I couldn’t figure out why it’s done that way and why couldn’t it be simpler :confused:

Translucency is a no-go on mobile VR. Maybe image with white background and black spot would work, using modulate blending ?

I am confused, I thought you were asking about the material function we already have called Sphere_AO? somebody mentioned it by name up above.

The code snippet posted looks like the same thing but much longer for some reason as far as I can tell. Maybe some additional below the horizon math that isn’t needed in your case.

It does work exactly like you say, except that the sphere is purely virtual, there is no actual sphere for the leg you will merely set a parameter in the material pretending it is there. That really isn’t so hard, you can grab a bone position in the blueprint by using Get Socket Location. Then set to update a material param collection or MID value. Then you place the material on more of a box or flat plane that is closer to the ground.

Showdown VR used something much simpler, it just used a blob texture on translucency.

If translucency is a no-go then I don’t see how you can do it other than placing the Sphere_AO material function into your ground material like my alternate suggestion.

Oh, I didn’t know UE4 already has that. I was talking about that custom code, yeah. What would be the best example to look at for UE4’s Sphere_AO ?

When I checked Showdown scene, all I saw was a sphere mesh with black on white image (blob shadow image) attached to the robot and massive network of noodles in the material editor :confused: There are some custom UV maps involved too. Not quite sure why.

I am guessing it was using the WorldPositionBehindTranslucency setup that I described above. Its just a way to get the worldpos of the floor underneath the character.

And making them spheres is just another shape they could have been boxes or planes, but the spheres make sure the shape covers the whole area on the ground around the foot, and might fit the shape of the texture better than a box so maybe thats why it was a circle.

All you need to do to use it is tell it the sphere position and radius. There are no existing examples yet but it should be easy to try it out.

In terms of ‘massive amounts of nodes’ IIRC, it was so the shadow opacity faded down when the foot steepped higher. All manual hackery. If you use Sphere_AO function you shouldn’t have to do that as it should happen naturally when the animation plays and raises the leg bones (assuming you set the sphere to be the foot and update on tick to bonepos). That is the beauty of using the function rather than manual nodes. But you can probably get something ‘nicer’ looking with manual nodes and textures since you can shape the shadow exactly to the foot etc. So pick your poison, something that works in all cases OK, or something that needs a lot of custom setup to look good in one case.

Sorry, I give up :frowning: I don’t understand how on earth this thing works :confused: Can someone please really explain in terms that a non-technical artist could understand ? (after spending entire evening on Showdown demo, it seems that not only Material setup is mind numbing, but also assets had to be prepared in a certain way; I couldn’t figure it out for **** :confused: )

Here is my setup:

blob_shadow01.png
Full size: http://s23.postimg.org/hhw7oi42h/blob_shadow01.png

blob_shadow02.png
Full size: http://s28.postimg.org/cymd8m50r/blob_shadow02.png

blob_shadow03.png
Full size: http://s9.postimg.org/6o4odt14d/blob_shadow03.png

So, at this time it doesn’t do anything at all - doesn’t offset texture to be a few units above the floor and I am sure if the critter would walk along, it wouldn’t project straight down either. Plus if I move the plane with blob shadow texture above the foot, it will also darken the foot.