Tuesday, July 21, 2015

Living In a Material World

I've figured out why Tech Artists are always so happy: working with materials is super fun.

I'll have more to say on Blueprints and node graph editing later, but building shaders in Unreal is pretty amazing. If you're not familiar, you basically choose a general type of materials, such as Surface, Decal, or Translucent. You're then given a node with a bunch of inputs, and you can build nodes in any way you want to feed into those inputs.

The brilliance comes in the ease (and daresay joy) in building nodes combined with the ease of previewing. As you're building up your graph, you can preview the entire material live, of course, but you can also preview any specific node to see how it's contributing to your final look.

The first shader I built, with the help of a guide, was a selection circle. The theory is pretty easy. Take a radial gradient and power it to sharpen the edges. Then take a second gradient with a smaller radius and subtract it. Feed that into the emissive multiplied by a color and glow factor, and you're done. It's important to set up all of these values as parameters so they can be easily manipulated in material instances.

There's a upgrade to this material that I'd like to make: change the circle to be a dashed line that spins. I had a shower thought this morning on how to accomplish that. Keep in mind my material experience is practically zero, so there's a good chance this is not correct or ideal.

First I take the UV of the pixel I'm rendering and determine the angle of the vector it forms with the center of the texture. I then mod that by the angle of frequency for my dash. I then mod the original angle by X * Frequency where 1/X is the ratio of dash (so 2 means evenly dashed).

Conceptually, if the two mods are equal, draw black. If they're not equal, draw white. This essentially will create a pinwheel of black and white. I then subtract that from my circle prior to applying color and glow. I can accomplish this without a branch by subtracting the two mods and multiplying since the equal values will subtract to zero. I don't have to worry about multiplying the white with values above 1 since I clamp before applying color already.

So anyway, I think that will give me the look I want. I'll try to play later tonight with it.

The other material I want to make is for the effect when you click a tile. Upon clicking a tile, I want a box to appear with outlined glowy edges, a translucent body, and fading as it goes up.

I found a Liaret tutorial last night that builds a Tron material. This is a great start for what I want. The idea is to take a gradient texture, power it to sharpen, then rotate it for each side and apply. This makes a nice outline on the material. You the multiply be a glow factor and color, plus add parameters for glassiness and metal until you get the shine you're looking good for.

The next steps I'd make would be to set the opacity of the main body, possibly with a radial gradient. Then I'd make an opacity gradient based on the local height so that it blends out toward the top. A cube would have no top face.

That's the theory at least! Let's see how that goes.

No comments:

Post a Comment