No announcement yet.

Procedural Generation using Noise

  • Filter
  • Time
  • Show
Clear All
new posts

    Procedural Generation using Noise

    So for my final year of Uni I decided upon writing my dissertation on the merits of procedural generation, with the practical side being that I generate a fairly basic solar system with orbital paths and procedurally generated textures. However, I've hit a snag as I have absolutely no idea what I'm doing. The noise function in the UE4 Material Editor is depressingly basic, with no real levels of customisation or fine tuning that could allow me to generate reasonably earth-like looking planets. I know I'll probably have to delve into C++ using libnoise, but is it possible to do the following using purely blueprints:

    Generate and texture earth-like planets, rocky moons, and reasonable looking star surfaces?

    I've maybe about 10 hours experience using the engine now, looking up reference guides for blueprints, but there is still a lot I don't understand. I understand the blueprint system is very powerful, but I imagine it does have limitations, and I notice that there aren't other noise functions that might be useful (like Voronoi noise for rocky planets)

    Have you looked at Substance Designer? This will help you generate textures that can be tweaked at runtime.
    I'm @londonisunreal, the organiser of the London Unreal Engine Meetup group.


      It depends on how detailed you need these planets to be. For instance, if you want to actually shape the mesh, you are going to want to delve into C++ as their procedural mesh sculpting in blueprint isn't quite there yet.

      If you just want to have procedurally textured spheres and properly populated solar systems, then blueprint and the material editor can accomplish what you are after. But, you are going to have to figure out the noise functions you need and create them in blueprint/material editor. I use voronoi for my map generation, but it is all built from scratch.
      Map Generator 1.0
      Map Generator 2.0
      Map Generator 3.0


        I use voronoi for my map generation, but it is all built from scratch.
        Yeah, I was looking at your map generator which is really impressive, but its just trying to figure out to what extent the blueprint/material editor can do this stuff. I imagine you can create custom noise functions but only in the blueprint editor using math expressions. When I look at procedural texture generation in the UE4 wiki its only in C++ and it requires the use of an already existing texture, which makes no sense to me since I thought the whole idea is to create a texture using only algorithms.

        I haven't use Substance Designer, but as far as I can see its an external tool, and the main idea is to be able to generate a texture from scratch using a custom made noise function, tweaked for earth-like planets to make it look realistic.


          So I talked with my supervisor and he suggested that I use something like Java to generate a heightmap with whatever noise function I create, and I can pass it into UE4 which would automatically load it when the editor starts up. Would this be a more viable option? My project is mainly more about the concept behind the generation rather than rendering it in Unreal Engine.


            If you are doing your thesis shouldn't you have a pretty decent understanding of programming anyway? Generating a complex texture within unreal is not really it's intended function so you are definitely going to have to work with some code to get it done. Having said that there are plenty of other ways of generating procedural items that don't rely on using a heightmap/texture map to create them.


              Well I kinda do, but only with Java. C++ feels like a completely different animal given the manual memory allocation, destructors and generally different structure, not to mention the use of header files. Can UE4 automatically detect any textures that are created by external programs and then apply them to objects?


                Maybe off-topic suggestion: If you don't want to learn c++ and don't care about visuals so much, there are a lot of simpler engines out there that can draw textured objects.


                  What your professor suggested sounds good (making your own basic noise function and sampling that).

                  For what it is worth, you can do all of that inside of the Custom node in materials. I'd suggest first starting with some simple Value noise. That is a style of noise that is often confused with perlin noise. First make a simple psuedorandom number code (ie.... frac(x * SomeLargePrimeNumber * (x + some largeprimenumber)) as a super basic example). The idea is it needs to return the same value for a given input.

                  Then make some code to sample it at intervals... which is basically like taking floor of current value and then using frac of that number to lerp between random(x) and random(x+1).

                  Then you just need a line that adds octaves of the noise, where the scale gets doubled and the intensity multiplied by persistence at each step.

                  Should be possible to get a basic version of that with only a few lines of code.

                  The difference between Perlin noise and this simple value noise is that perlin noise uses a bunch of random vectors to generate gradient maps instead of using raw pseudo random numbers but the code is way longer for perlin.

                  fwiw a simple value noise in the custom node is something I want to do soon as well but I keep getting assigned other tasks. I wanted to do it for experimenting with clouds.
                  Last edited by RyanB; 09-28-2015, 01:39 PM.
                  Ryan Brucks
                  Principal Technical Artist, Epic Games


                    Oh, cool. So when you say starting with some simple value noise, do you mean creating a math expression to do so? I haven't started looking into the algorithms yet for generating noise, but I will do in the coming days. I've just been starting with the basics and trying to get a feel for how I want the flow of the program. In reply to the suggestion of using another engine, I picked UE4 mainly because I'd like to have some experience in using it for when I graduate, maybe to help with applying for game development careers.


                      Yes I am talking about the custom node in materials. It is a place to write hlsl script. It is a very simple language compared to c++.
                      Ryan Brucks
                      Principal Technical Artist, Epic Games


                        Just to throw my input in there, you're most definitely going to want to make your own custom noise node. The noise node that is built into UE4 can do some neat things but as soon as you want to do anything really outside the box with it, you start to see the limitations it has.

                        Click image for larger version

Name:	R30nTUy.png
Views:	2
Size:	874.2 KB
ID:	1088339

                        I worked on this little planet shader for about half a day before I realized what I wanted to do wasn't really possible with the tools at hand.
                        It has clouds, a basic atmosphere, landmasses, city lights, and normals...that are all generated from scratch. However, it was hell getting all that to work and in reality it only looks like that in the material editor. It basically broke when I brought it into world space.

                        The main issue I had is that the noise node does not play well with being colorized, all. I had to do some serious workarounds to get the clouds and city lights working (couldn't overlay the clouds or lights, so had to combine them and then plug them into the emissive channel), so yeah, you're going to want to make your own noise node. Also, look at that instruction count; it's enormous. The noise node is pretty expensive to use, so you have to consider that as well.

                        Edit: @RyanB Is it possible to look at the underlying code that the material nodes have? I've wanted to crack open the standard noise node for a really long time but have never known if it was possible or not.
                        Last edited by JamesEmory; 09-28-2015, 03:49 PM.


                          Yes you can find all of the material nodes under:


                          For example the noise header is:


                          The actual code for most of the nodes is under:


                          In the case of the Noise function though, the material node references a Noise function from elsewhere that is pretty hard to find.
                          Look at line 1164 of Engine\Shaders\Common.usf:

                          Looking at that function, we can see the bulk of the lifting is done by this function here (which is conveniently right above the previous line):

                          float Noise3D_Multiplexer(int Function, float3 Position)
                          	// verified, HLSL compiled out the switch if Function is a constant
                          		case 0:
                          			return SimplexNoise3D_TEX(Position);
                          		case 1:
                          			return GradientNoise3D_TEX(Position);
                          		case 2:
                          			return PerlinNoise3D_ALU(Position);
                          		case 3:
                          			return FastGradientPerlinNoise3D_TEX(Position);
                          		// currently not accessible through UI
                          			return ComputeRandomFrom3DPosition((int3)Position).x;
                          	return 0;
                          That calling function loops over this Noise3D_Multiplexer for each level and accumulates the noise while reducing the strength at each iteration by the persistence (invlevelscale here):

                          Now you could easily follow those function names to research how each of the methods is implemented.

                          	LOOP for(uint i = 0; i < Levels; ++i)
                          		// fade out noise level that are too high frequent (not done through dynamic branching as it usually requires gradient instructions)
                          		OutScale *= saturate(1.0 - FilterWidth);
                          			Out += abs(Noise3D_Multiplexer(Function, Position)) * OutScale;
                          			Out += Noise3D_Multiplexer(Function, Position) * OutScale;
                          		Position *= LevelScale;
                          		OutScale *= InvLevelScale;
                          		FilterWidth *= LevelScale;
                          You could easily build a noise function out of these pieces and make your own version of the part that returns the random number.
                          Last edited by RyanB; 09-28-2015, 04:32 PM.
                          Ryan Brucks
                          Principal Technical Artist, Epic Games


                            The main issue I had is that the noise node does not play well with being colorized, all. I had to do some serious workarounds to get the clouds and city lights working (couldn't overlay the clouds or lights, so had to combine them and then plug them into the emissive channel), so yeah, you're going to want to make your own noise node.
                            I do not see how the noise node and your issues are related. You can do all that kind of overlay stuff. If you are having issues applying a color gradient in the way you want, using a different method to generate the gradient will make no difference to the problem. Hooking up the lights to the emissive channel is probably the right thing to do anyways so I don't see how that is related to issues with the noise node. The only 'issue' I am aware of with the noise node is that it can be difficult to get the type of noise you might want.

                            Also if you are having trouble matching the material preview and a mesh in the world, I suggest you instead use "BoundingBoxBased_0-1_UVW" as the input to position of the noise node since that will use an entirely local coordinate basis. You can still scale it as needed by multiplying.
                            Ryan Brucks
                            Principal Technical Artist, Epic Games


                              My main issue was that I was wanting to sample multiple black/white values to colorize and was not finding any efficient means to do so.

                              As far as the city lights go, yes, hooking those up to the emissive was right. But the deal was that the clouds could not be overlayed or added to the existing colored noise without destroying the colors. So I had to add the clouds and lights together into the emissive channel.