Download

Adding a new type of noise to the already preset noise function in Material editor

Hi I am trying to add new type of noise functions to the already existing noise function present in material editor.

Just to test, I added a new type to enum variable to the already present enum in the MaterialExpresionNoise.h and it now looks like this


UENUM()
enum ENoiseFunction
{
	/** fast (~94 instructions per level) */
	NOISEFUNCTION_Simplex UMETA(DisplayName="Simplex"),
	/** fast (~77 instructions per level) but low quality*/
	NOISEFUNCTION_Perlin UMETA(DisplayName="Perlin"),
	/** very slow (~393 instructions per level) */
	NOISEFUNCTION_Gradient UMETA(DisplayName="Gradient"),
	/** very fast (1 texture lookup, ~33 instructions per level), need to test more on every hardware, requires high quality texture filtering for bump mapping */
	NOISEFUNCTION_FastGradient UMETA(DisplayName="FastGradient"),
	/** A custom function made by me to do sphere random in 3d plane */
	NOISEFUNCTION_SphereRandom UMETA(DisplayName = "SphereRandom"),
	NOISEFUNCTION_MAX,
};

And in the common I added another case


float Noise3D_Multiplexer(int Function, float3 Position)
{
	// verified, HLSL compiled out the switch if Function is a constant
	switch(Function)
	{
		case 0:
			return SimplexNoise3D_TEX(Position);
		case 1:
			return GradientNoise3D_TEX(Position);
		case 2:
			return PerlinNoise3D_ALU(Position);
		case 3:
			return FastGradientPerlinNoise3D_TEX(Position);
		case 4:
			return SimplexNoise3D_TEX(Position);
		// currently not accessible through UI
		default:
			return ComputeRandomFrom3DPosition((int3)Position).x;
	}
	return 0;
}


This was just to test if the function is visible in the material editor node or now. Sadly it was not visible. Any other change which I should do?

If anyone else knows how to do this…