Development report, 24 Sep. 2015
(I’ll be posting reports of my progress and findings once in a while)
A couple of things I learned these days.
Mathematically computing waves inside the shader is not the way to go. UE-s means of pattern generation are not that convenient to procedurally calculate a Gerstner ocean via math. A Tessendorf model would be even harder to implement.
The idea I had was to model the large waves via math, and then use height and normal maps for the small detail. While easy on the texture side, this method would blow up my material complexity to the point it was no longer worth it.
On the positive side, sine waves can be blended together to simulate more “calm lake” kind of displacement. The pattern can be scaled and re-blended at will, might be a good procedural way to get rid of tiling artifacts, if blended with a height map. More on that once I experiment with that. Also - Aurora Borealis can be easily represented with this method, using sine waves of different lengths and blending colors through them. The idea is to have several sine waves (panned in the same direction) acting as masks for lerps with non-zero lower value. The exact top and bottom values are to be determined via trial and error. Then the lerps can be multiplied together for one big pattern - or be used as masks to blend colors you want to have in your Aurora Borealis. Hope will have a working example soon.
(early experimental example of sine-based pattern, an overlay of 2 horizontal and 2 vertical sine waves)
The theory behind getting a sine wave out of a sine function and local coordinates is the following:
What it does: takes the local coordinate values from either U or V directions and feeds them to the sine node. The resulting sine function varies between -1 and +1, but we actually lose the negative values as they cannot be represented as color information. So we add 1 to make it vary between 0 and 2, and divide by 2 to bring it to the 0-1 interval we can use.
This approach is easy to parametrize:
This wave can be placed inside a material function to be called upon with necessary inputs for a procedural sine-based pattern creation. The only problem would be UE panners not accepting inputs. So you might have to place a vector2 input instead of the TextureCoordinate node and feed the panner directly into the function as an input, but remember - the scaling and offsetting will affect the panning too.