open a splatmap in photoshop

I have a splatmap in .png format. It looks fine in Unity, but when I open it in photoshop the R, G, B channels are blank. What format do I need to open it in to edit it? Thanks.

The reason they are blank, is because photoshop opens the .png format with the alpha channel directly applied to the layer, instead of having it as an alpha channel. When you inspect the splat texture in Unity, the black areas are areas where the alpha channel is in use. And these areas will simply not show up in photoshop. Here’s a way to solve it from the top of my head:

  1. Change whatever script you are using to export the splat map, so it will set the .a component of the color to 1.
  2. Open in Photoshop and modify whatever you need to modify.
  3. Reapply to the splat texture by a script. A script I just tried to do for you, though it is not tested much. So BACK UP!!! Remember that the splat texture is saved as part of the terrainData asset, and as such will still be changed, even if you don’t save the scene.
    I reconstruct the alpha to whatever is leftover from the rgb components. The four components added should always be 1 in total…
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
 
public class SplatWriter : ScriptableWizard
{    
    public Texture2D textureToSplatify;
	
	[MenuItem ("Terrain/Texture/Splat Writer")]
	
	static void createWizard() {
		
			ScriptableWizard.DisplayWizard("Select texture to splatify", typeof (SplatWriter), "Splatify");
		
	}
	
    void OnWizardCreate () {
    	
        Texture2D splatTexture;	
        splatTexture = (Texture2D) Selection.activeObject;

        if (splatTexture == null) {
            Debug.Log("Apparently your selection is either void, of a format that can't be cast as texture2D, or who knows what. Aborting...");
            return;
        }

        if (splatTexture.width != textureToSplatify.width || splatTexture.height != textureToSplatify.height)
        {
            Debug.Log("The splat texture, and the texture to splatify, differs in size! Aborting...");
            return;

        }

        Color[] theseColors = textureToSplatify.GetPixels(0, 0, textureToSplatify.width, textureToSplatify.height);
        Color[] theseColorsSplat = splatTexture.GetPixels(0, 0, splatTexture.width, splatTexture.height);
		
		for (int i = 0; i < theseColors.Length; i++) {


            float alphaComponent = 1 - (theseColors[i].r + theseColors[i].g + theseColors[i].b);
            theseColors[i].a = alphaComponent;

			theseColorsSplat[i] = theseColors[i];
			
		}

        splatTexture.SetPixels(theseColorsSplat);
        splatTexture.Apply();
		
   	    Debug.Log("Done. Succes?");
    }
 }

Also can see the splatmap with:

  • Open png in photoshop,
  • Layer / Layer mask / From transparency
  • Then you can disable the layermask (or adjust its density in properties) etc.
3 Likes

Great! Thanks!! The script i’m using to export the splatmap is part of a bigger asset, I haven’t picked through it yet. I really appreciate you responding with code! I’ll post back with the results.