Parallax Scaled Configs - Gameslinx/Parallax-Continued GitHub Wiki

image

Parallax Scaled Configs

Prerequisites

Cache File

Before creating a parallax scaled config you must replace the planet mesh with Parallax's cache file:

@Kopernicus:FOR[zYourModName] // The z is important for patch ordering. You could also use :AFTER, the ordering is up to you
{
    @Body[Moho]
    {
        %Debug
        {
            %exportMesh = True
            %update = True
        }
        %cacheFile = ParallaxContinued/Models/ScaledMesh.bin
    }
}

If your planet has an atmosphere and will use Scatterer, you might want to replace the %cacheFile line with

%cacheFile:NEEDS[!Scatterer] = ParallaxContinued/Models/ScaledMesh.bin

Note that when using this you MUST add 'usingStockMesh = True` to your scaled config, see below

Maps Export

Before you get started on your scaled config, you should use the included texture exporter (Ctrl + P) or the standalone texture exporter (linked in announcements in the Kopernicus discord) to export your planet maps.

You should make a note of the minimum and maximum altitudes reported by the exporter after exporting, you'll need these!

You should use this exporter because it exports the accurate normals for your planet's terrain which is crucial you use for the scaled planet. The exporter also produces a normalised (0 to 1) heightmap where 0 corresponds to the minimum terrain altitude and 1 corresponds to the maximum terrain altitude.

Parallax Scaled Config

The scaled component of Parallax is pretty simple to set up. The stock Parallax configs provide these in a separate folder named 'Parallax_StockPlanetTextures' but this isn't necessary for planet modders.

The default node setup is as follows:

ParallaxTerrain
{
    Body
    {
        name = ...
        emissive = True/False

        // This is your terrain node
        ShaderProperties
        {

        }

        // This is your scaled node
        ParallaxScaledProperties
        {

        }
    }
}

For this wiki page we'll only be focusing on the ParallaxScaledProperties node.

Example Node

This is a basic scaled properties node which adds textures to the scaled planet. This example uses the "FromTerrain" mode which will be the most commonly used

ParallaxScaledProperties
{
    // Possible modes:
    // FromTerrain
    // Baked
    
    // Altitude in meters - Get these from the GUI readout after exporting a planet's textures
    // These are the min and max altitudes of your PQS terrain
    minTerrainAltitude = -1393
    maxTerrainAltitude = 6768
    
    // If your planet has scatterer applied to it, add usingStockMesh:NEEDS[Scatterer] = True here

    // Shader modes
    mode = FromTerrain
    Material
    {
        _ColorMap = Parallax_StockPlanetTextures/Kerbin/PluginData/Kerbin_Color.dds
        _BumpMap = Parallax_StockPlanetTextures/Kerbin/PluginData/Kerbin_Normal.dds
        _HeightMap = Parallax_StockPlanetTextures/Kerbin/PluginData/Kerbin_Height.dds
        _PlanetBumpScale = 1
        Keywords
        {
            // None defined
        }
    }

    // By default, Parallax Scaled reads a lot of material properties from the terrain material defined in the ShaderProperties node
    // The TerrainMaterialOverride node allows you to adjust these. In this example, the _Tiling value on the scaled material does not inherit from the terrain material, and is instead set to 0.0009
    TerrainMaterialOverride
    {
        _Tiling = 0.0009
    }
}

Notable Adjustments

Kopernicus On-Demand and Scaled Textures

If your planet's Kopernicus ScaledVersion textures use the OnDemand node as follows, you should read this section:

ScaledVersion
{		
    type = Atmospheric
    fadeStart = 71500
    fadeEnd = 143000
    Material
    {	
        ...
    }
	OnDemand    // The relevant node
	{
		texture = OPM-Thatmo/Textures/PluginData/Thatmo_Color.png
		normals = OPM-Thatmo/Textures/PluginData/Thatmo_Normal.png
	}
}

This works fine for Kopernicus On-Demand but when using Parallax Scaled, Kopernicus will try and unload the parallax textures and get it wrong! Parallax handles on-demand loading for scaled space itself so don't worry, you're not missing out on the advantages of on-demand loading!

The fix is simple! You need to write a module manager patch that removes this OnDemand node and instead adds the texture and normals values to the ScaledVersion material node.

You should also make the texture and normals values point to some dummy very low resolution texture (like a 4x4 black square) because there's no point loading them when parallax is installed! Save some RAM and VRAM. Looking at you ballisticfox

List of Keywords

Here are the possible keywords you can use on a scaled material:

Name Exposed Parameters Function Superseded By
EMISSION _EmissionColor Sets up your scaled terrain textures to use emission. This is set automatically if your ParallaxTerrain body has 'emissive = True'. You will likely not need to set this unless you ONLY want emissive terrain from orbit. Nothing
OCEAN _OceanSpecularPower, _OceanSpecularIntensity, _OceanAltitude Enables the ocean from orbit and exposes specular params. By default this takes the ocean colour from your planet's actual ocean. Ocean altitude defaults to 0 (sea level) OCEAN_FROM_COLORMAP
OCEAN_FROM_COLORMAP _OceanSpecularPower, _OceanSpecularIntensity, _OceanAltitude The same as OCEAN, but takes the ocean colour from the planet's _ColorMap Nothing
ATMOSPHERE _AtmosphereRimMap Enables a simple atmosphere gradient on your planet. You should use name:NEEDS[!Scatterer] = ATMOSPHERE to apply the keyword to make sure it's replaced by Scatterer if it's installed Nothing
SCALED_EMISSIVE_MAP _EmissiveMap, _EmissiveIntensity An additional colour map for emission, commonly used for molten worlds. Use _EmissiveIntensity to control how bright the emission is, and use colour in your _EmissiveMap. Nothing

"Baked" mode

If you choose to use the "Baked" mode instead of "FromTerrain", all you need to do is remove the TerrainMaterialOverride node if you have one. The Baked mode implies your planet has detail baked into its maps and can forego the parallax terrain textures. Specular is stored in the alpha channel of the _ColorMap. For simple planets like asteroids or water worlds, use this, as it skips needing to load or shade the terrain and can improve performance.

Extra Tips

  1. For atmospheric planets with oceans or smooth terrain, you might not want to see skybox reflections. To fix this, in the TerrainMaterialOverride node you can use _EnvironmentMapFactor = 0 to disable the skybox reflections on planets you don't want them to appear on

  2. _PlanetBumpScale should be kept at 1.0 if you want truly accurate normals that conform to the real terrain geometry