Dynamic Materials for Particle FX

Any value that’s 0 or less than 0 becomes 0, any value that contains a fractional value becomes 1. if you ceil a gradient, any of the “point” values just become 1.0. In my example, I have a smooth gradient from 0 to 1 from my frac. Then I subtract to push most of my gradient negative, leaving 15% of my gradient in the positive range. Then I run ceil on it so that “sliver” of my gradient becomes 1.0 across the whole fractional range of the gradient, making a solid brick of white to use as a mask.

Frac and Ceil are best friends.

Nice Wyeth, I’ll have to hook that up to our screens and drop the static texture.

Wyeth - I don’t know why I never actually tried to take it that step - but sure enough it works brilliantly.

ooh, nice. the noise and the scanline distortion look very sweet! thanks both of you, that’s going to be quite useful.

@Doug Great dynamic particles/material tutorials! I wanted to add that there’s a great plugin for AE. It tiles your fractal noise texture without having to do the traditional offsets in photoshop.

Go to AEScripts.com and search for YY Seamless.

[QUOTE=whooosh;15417]@Doug Great dynamic particles/material tutorials! I wanted to add that there’s a great plugin for AE. It tiles your fractal noise texture without having to do the traditional offsets in photoshop.

Go to AEScripts.com and search for YY Seamless.[/QUOTE]

Thanks man that will help for sure. I knew there had to be a better way I just didn’t bother to look. I’ll be sure to use it in the future. :D:

Any recommendations on Liquids? I’m thinking slow squirts of blood, thick, non mist water splashes.

I’ve seen procedural approaches to the misty variants with things like alpha erosion. It gives decent results but they also often just look like white dirt. Thick liquid however, is a whole different beast. Did anyone crack it, or are flipbooks still the way to go with this?

My favorite ingredients for this one are:

An 8 or 16 frame filmstrip texture of water breaking apart from a big shape into little shapes

A normal map that I can use to distort the UV lookup into each frame of the above animated texture. The normal map itself scrolls continuously, and the intensity of the UV distortion can increase over time, further helping to break apart the shapes as the particle dies, as well as adding cool fluid motion. I also like layering the UV distortion on top of the animated texture, because if you slow the particles down, you won’t notice the frames flipping if they end up less than 30 fps.

Then if you can afford it, i’ll add a normal map too (this one used for lighting not UV distortion). It gets manipulated the same way the diffuse texture would (animated and distorted), but then the normal vector can be used for refraction and/or high frequency highlights by sampling a cube map.

At GDC I think Eben had a cool trick for getting high frequency highlights without using a cube map (maybe it was just sampling a 2D texture), but I need to watch the lecture again and refresh my memory there.

It’s expensive, but if you can get refraction in there as well it really starts to get liquidy!

Sorry i don’t have any shader networks to share. We just use raw HLSL, but for quickly conveying some of this stuff you can’t beat a quick shader network…

Anyway - just my off the cuff thoughts I’m curious what other folks are doing!

Refraction / screen distortion is always great eye candy :slight_smile:

More often than not I use a spherical env map for reflections/highlights (rather than a full cube map) - normally does the job and is pretty artist friendly. If your particle is based on a normal map (possibly with alpha), then you can take the entire colour of the pixel from the env map (so you don’t need a diffuse texture).

Getting the normals in there is the trickier part - spherical env map and screen distortion both need view space normal, so there’s only one to calculate.

Depending how close the particles / effects are seen, you may be able to get away with not using a normal map at all - the ddx/ddy derivatives of a mask texture will give you view/screen space semi-normals that are close enough for jazz. If seen close, it breaks up across the 2x2 pixel blocks that the derivatives are calculated across, but at mid distance it looks fine.
This also means you only need a single channel (or summed RGB channels) mask for the shape of the particles - which can be UV-warped via a distortion texture and thresholded down to change the shape over the life of the particle. As it thresholds down there’s less range for the ddx/ddy so it starts to break up, but as long as it’s fast and not too close, it’s a cheap way to do it.

Pretty tweakable and artist-friendly as it boils down to a single mask texture for the shape of the particle (with gradient controlling how shape changes over time, optional distortion texture to warp it) and an env map for the colour (with the highlights / reflections drawn in - you can also use the env map alpha channel for controllable fresnel or other alpha effects).

Like Drew says though - the majority of the “sell” of the effect is down to the motion, so the more controllable the movement of the particles/ribbons, the more control you have over changing the texture shapes and the more options you have for scrolling and distorting UVs the better :slight_smile:

Great thread you guys. I am inspired to fire up my UDK here at home at start tinkering. Not having much access to the shaders in our game make a lot of this very instructional for me.

I too am looking to rethink out water/fluid particle look. I like the idea of having a flipbook from a sim at the heart of the motion though I am pretty sure adding the uv distortion will help add detail and in slow time situations. Rather than have the flip book handle the breaking apart which would limit you to the number of frames I am thinking a looping flipbook would be better and let alpha trickery make the shapes spread and then split into drops.

As for the lighting/spec issue our severe shader limitations have kept us from trying anything with cubemaps or normal maps etc. We have mostly been limited to cheap gradient remap tricks or angle based falloff tricks. I like what Ebin presented at GDC with the sparkle layer because it still seemed pretty cheap and the result was nice.

Not sure if I can find it online somewhere but there was a talk on the water FX of Bioshock at GDC a few years back ad the had a few tricks for getting the wet look. The one I most remember was the had spec on the particles but didn’t see it a lot so they put a light on/near the player/camera to always bounce a light of the particles in front of your face. Thinking about that setup helped as a foundation for a lot of fake specular ideas we tried.

Ya, useful info, and can anyone tell me where I can find the info on pdf conversion?

This might be a dumb question, but say i was stuck writing shaders from scratch in a text editor, how would I create the equivelant of a Texture Coordinate node in Unreal from scratch?

Thanks, awesome thread.

[QUOTE=rgkovach123;19794]This might be a dumb question, but say i was stuck writing shaders from scratch in a text editor, how would I create the equivelant of a Texture Coordinate node in Unreal from scratch?

Thanks, awesome thread.[/QUOTE]

Well, you can’t really think in nodes if you are writing the shader by hand. There is a whole lot of stuff going on behind the scenes.

Anyway, you’d add this to the struct and then call it where you need it.
float2 Texcoord : TEXCOORD0;

What kind of strange voodoo is hidden in the nodes in this network? I am trying to recreate this effect in HLSL…
Here is some psuedo code…

    float2 bias = IN.UV0 + (-0.5f);
    float inverseDot = 1.0f - (dot(bias, bias));
    float power = pow(inverseDot, falloff);
    float2 uvs = bias * power;
    uvs *= distort;
    uvs += IN.UV0;
    float4 DiffuseTextureSample = DiffuseTexture.Sample(SamplerAnisoWrap, uvs);
    return float4(DiffuseTextureSample.rgb, 1.0f);

I am getting some strange repeat behavior when the Bulge goes beyond -1.
Thanks!


I think I got it working, I was just confused by the behavior when the distortion amount goes beyond -1. The texture doesn’t repeat the way I saw it in my head…

[QUOTE=Strobel;15374]You can even use Tex Coords to create procedural white noise like on a television.

[/QUOTE]

Back again with another question… I am trying to re-create this effect without the benefit of a node-based editor - just raw code…
I think i got everything working correctly, but I wanted to know if the noise pattern is achieved by oversampling a super dense pattern, or if my math is wrong…
Here is what my noise pattern looks like up close:


When I zoom out, I get crazy over-sampling that creates a noisey look… just wondering if the noise effect is truely random or just a super-high frequency pattern.

Here is a code snippet:

    
    float2 uvs = IN.UV0;
    uvs.r = frac(uvs.r);
    uvs.g = frac(uvs.g);
    float2 cosine = cos(uvs * 400.0f);
    float2 sine = sin(uvs * 400.0f);
    cosine = cos(cosine * 23.0f);
    sine = sin(sine * 34.5f);
    cosine *= sine;
    float noise = cosine.r * cosine.g;