Jump to content

Procedural Planet Textures using Adobe After Effects


Recommended Posts

Creating Procedural Planet Textures (Heightmap & Colour) using Adobe After Effects

Abstract

To create an Adobe After Effects template that will allow for the generation of Planet/Moon Heightmap and Colour Maps for use with KSP by utilizing fractal noise layering to allow for ease of use by those that may not understand noise generation or subsequently, PQSMods/libnoise functions.

The Adobe After Effects project can be download and used from here: https://www.dropbox.com/s/zss8ydp80zm6h7b/Planet Textures.aep?dl=0

-----

I recently rediscovered the power and effectiveness of After Effect's Fractal Noise libraries whilst working on unrelated projects and considered that it would be a powerful tool when used to create base textures for planetoids in KSP; if utilised correctly.

Due to the way After Effects generates the noise, most noise created would be generated outside of the -180 to 180 degrees phase and therefore would not be seamless in the workspace and also the noise is created in a rectangular image space and therefore there would be significant 'pinching' distortion at the poles. To rectify this, the noise image space can be distorted using polar deformation to remove this issue and finally some manual seam blending can be introduced using a small mask to cover any inconsistencies that blends in with its surrounding environment.

Finally, the resulting greyscale heightmap can be colourized depending on the lightness using a custom gradient scale to create a coloured ScaledSpace texture that varies with colour proportional to altitude. These textures can be rendered out of After Effects (at 8192x4096 in the attached project) for further use within KSP or for additional image manipulation work. The greyscale heightmap can be passed through a normal map generator to give you the bump map to be used in-game (remember that KSP uses inverted Red to the Alpha channel and the Green channel duplicated to RGB).

Anyway, I have done some quick and dirty previews as to what can be achieved with not a terrible amount of effort, as you can see, bodies with complex and noisy terrain can be generated alongside those with mostly flat, rounded slopes:

nyP1JBW.gifXrubzac.gif

V5ZrmHx.gifnQcS0u2.gif

The above planetoids have all been generated using textures rendered straight from After Effects with the normal maps used being from the http://cpetry.github.io/NormalMap-Online/ tool by utilizing the greyscale heightmap.

KbroFCl.png

Above is a preview of one of the example bodies shown from Front, Left, Back, Right, Top & Bottom respectively to show the total lack of polar 'pinching'.

Mini-guide

Below I will list the respective stages of the process within After Effects to allow for the easy use of the attached project above.

Panel 1: Noise Layers

In this panel, you are required to generate the main features of the terrain by using multiple layers of fractal noise to build up a greyscale, rectangular base for your heightmap. 

QTK7eg4.png

As you can see, in the example above I have layered 6 noise layers to create the shown effect. The parameters listed against the Fractal Noise effect can be changed to alter the generated noise to your liking with a dynamic preview being shown in the composition work space. Ensure to layer blend your multiple noise layers to obtain the result you desire.

Panel 2: Polar Distortion

This panel requires no input by the user and simply takes the generated image from Panel 1 and applies the polar distortion required to create an even and consistent terrain distribution at the poles.

Panel 3: Seam Blend for Heightmap

The source image from Panel 2 is shifted horizontally by half a phase to show the seam error in the center of the image space. The mask in this composition can be resized, the feather adjusted and the opacity altered etc. to try and completely remove the seam whilst maintaining a good transition in the terrain on either side. This process can be seen below:

BbSkt3Y.png

OtPSVcT.png

This finalizes the greyscale heightmap for your body.

Panel 4: Colourization

The Colorama effect is applied to the source image from Panel 3 that allows you to create a gradient map that is directly proportional to the brightness of the texture. Many effects can be created here in the way that LUTs are used to colour terrain maps, realistically or not and even to reflect habitable Earth-like worlds.

In the example below a simple rocky style gradient has been applied.

en6LR0A.png

Panel 5: Spherical Preview

In this panel, you can rotate the colour map on the X, Y and Z axis (Y axis being the most useful) to give a real time preview of the body as a sphere.

Dd5QxY3.png

----------

Once you are happy with your terrain maps, simply add Panel 3 and 4's composition frame to the render queue and generate your heightmap and colour map textures respectively. Ultimately, a Kopernicus config will be required to be written to use your textures to create the body within KSP.

----------

Disclaimer: I appreciate the fact this may not be a desirable way to generate terrain for use within KSP as basing your terrain of a heightmap texture can cause some rough, pixel'y terrain at the pixel boundaries... especially on larger bodies. Nonetheless, PQSMods still remain a confusing matter to many people and this method may be "good enough" for some to achieve the results they require. I post this up as a fleshed out proof of concept and nothing more.

Edited by Poodmund
Link to comment
Share on other sites

  • 1 month later...

Upon further interest I thought I would post the following:

Using the base heightmap texture for the terrain altitude generation is probably not sufficient for how you want your body to be in-game. Adjust the deformity value in the required Kopernicus config (tutorials can be found elsewhere on this forum, search "Kopernicus Tutorial") to change the intensity of the difference in terrain altitude i.e.

Kopernicus
{
	Body
	name = *body name*
	{
		PQS
		{
			Mods
			{
				VertexHeightMap
				{
					map = *texture path*
					deformity = *value in meters*
				}
			}
		}
	}
}

I have posted below in the spoiler, the template config for the body as shown in the tutorial posted above for reference.

Spoiler

@Kopernicus:FOR[Test] 
{
	useOnDemand = false
	Body
	{
		name = Test4
		finalizeOrbit = true
		flightGlobalsIndex = 63614
		cacheFile = Test/Test4/Cache/test.bin
		Template
		{
			name = Moho
			removeAllPQSMods = true
		}
		Properties
		{
			description = Test4
			radius = 150000   
			geeASL = 0.5
			rotates = true
			rotationPeriod = 43200
			tidallyLocked = false
			initialRotation = 0
			albedo = 0.2
			emissivity = 0.9
			isHomeWorld = false
			timewarpAltitudeLimits = 0 17000 34000 51000 85000 170000 340000 510000
			ScienceValues
			{
				landedDataValue = 8
				splashedDataValue = 8
				flyingLowDataValue = 6
				flyingHighDataValue = 6
				inSpaceLowDataValue = 6
				inSpaceHighDataValue = 5
				recoveryValue = 5
				flyingAltitudeThreshold = 15000
				spaceAltitudeThreshold = 200000
			}
			biomeMap = Test/Test4/PluginData/biome.png
			Biomes
			{
				Biome
				{
					name = Test4
					value = 1
					color = 0,0,0,1
				}
			}
		}
		Orbit
		{
			referenceBody = Sun
			color = 1,0.8,0.25,1
			inclination = 1
			eccentricity = 0.03
			semiMajorAxis = 6288300000
			longitudeOfAscendingNode = 60
			argumentOfPeriapsis = 0
			meanAnomalyAtEpoch = 0
			epoch = 0
		}
		ScaledVersion
		{
			type = Vacuum
			fadeStart = 10000
			fadeEnd = 15000
			sphericalModel = False
			deferMesh = False
			Material
			{
				texture = Test/Test4/PluginData/test4_00.dds
				normals = Test/Test4/PluginData/test4_01.png
				shininess = 0.0
				specular = 0.0,0.0,0.0,1
			}
		}
		PQS
		{
			minLevel = 2
			maxLevel = 6
			minDetailDistance = 6
			maxQuadLengthsPerFrame = 0.03
			fadeStart = 15000
			fadeEnd = 20000
			deactivateAltitude = 25000
			deactivateAltitude = 115000
			Mods
			{
				VertexHeightMap
				{
					map = Test/Test4/PluginData/test4_heightmap.png
					offset = 0
					deformity = 7000
					scaleDeformityByRadius = False
					order = 1524
					enabled = True
				}
				VertexColorMap
				{
					map = Test/Test4/PluginData/test4_00.dds
					order = 60456
					enabled = True
				}
			}
		}
	}
}

 

Finally, if you are having issues creating the normal map correctly, the mod KittopiaTech can be used to generate the normal maps for you in-game. You can also adjust all the values and regenerate PQS mesh on the fly in-game which makes it a very handy and powerful tool to use when 'sculpting' your bodies.

Link to comment
Share on other sites

I can't work out how to do the polar inversion - you say it's easy and requires little input but google isn't returning anything useful for me apart from polar coordinates, which distorts the image differently to what yours looks like. If you could say how you managed to do this to your image, I would be greatful

Edited by Gamel0rd1
Link to comment
Share on other sites

  • 2 weeks later...

The Polar Distortion panel requires no input. It literally takes the composition from the Noise Layers panel, does a Polar Coordinates distortion twice (top and bottom), linearly wipes them towards the center to transparent and fudges it around a little to get a spherically wrappable image. i.e. take a look at a grid... its goes from this:

heG1bzd.png

... to this:

3mli27T.png

Lets take a look at a real example going through this process. Flat noise image:

tkCZNgf.png

Polar Distorted image:

dhpZ0tQ.png

This Polar Distortion 2nd Panel should need no user input. It does this process automatically. Does this help?

EDIT: In the uploaded After Effects file, I think I may have had the central region rotated to 180 degrees in the Polar Distortion panel... it shouldn't really matter but if you want to reset it back to 0, look in the image below as to how to do this:

lz6Q2LA.png

Edited by Poodmund
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...