Jump to content

Locating and Editing Planet Textures?


MajorStorm

Recommended Posts

MajorStorm: If you want to modify the heightmap (what's used in PQS) then yes, you can access it during code. Get the PQSMod_VertexHeightMap PQSMod on the Kerbin PQS and modify the MapSO on it.

Since the scaled space textures are loaded as read-only you can't modify them, you can only replace them.

Link to comment
Share on other sites

I've used this snippet for ages to convert unreadable textures back to a readable format:

public static Texture2D CreateReadable(this Texture2D original)
{
if (original == null) throw new ArgumentNullException("original");

if (original.width == 0 || original.height == 0)
throw new Exception("Invalid image dimensions");

var finalTexture = new Texture2D(original.width, original.height);

// isn't read or writeable ... we'll have to get tricksy
var rt = RenderTexture.GetTemporary(original.width, original.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);
Graphics.Blit(original, rt);

RenderTexture.active = rt;

finalTexture.ReadPixels(new Rect(0, 0, finalTexture.width, finalTexture.height), 0, 0);

RenderTexture.active = null;
RenderTexture.ReleaseTemporary(rt);

return finalTexture;
}

Link to comment
Share on other sites

Anyone know how to get the actual Scale space texture drawn over the surface of the planet?

It's easy to get the individual textures used for scaled space:


Texture diffuseMap = body.scaledBody.renderer.material.mainTexture;

//or

Texture diffuseMap = body.scaledBody.renderer.material.GetTexture("_MainTex"); //Substitute _BumpMap to get the normal.

//or

Texture diffuseMap = body.scaledBody.GetComponent<MeshRenderer>().material.mainTexture;

For the non-ocean planets this works fine and gives you the flat color map. For ocean planets you get a map that's black on the surface and clear on the ocean.

Using xEvilReeperx's snippet (which I now seem to find everywhere after I know what it is...) I can use the material to get ocean planet textures that look right in some cases. Also note that you need to use Apply() to the final texture before you can actually use it, you could do that with the texture returned by that method, or before the last line in that snippet: finalTexture.Apply();


var renderer = body.scaledBody.GetComponent<MeshRenderer>();

var diffuseMap = renderer.material.mainTexture;

var finalTexture = new Texture2D(diffuseMap.width, diffuseMap.height);

var rt = RenderTexture.GetTemporary(diffuseMap.width, diffuseMap.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);

Graphics.Blit(original, rt, renderer.material); //Note the addition of the material using a different overload here

RenderTexture.active = rt;

finalTexture.ReadPixels(new Rect(0, 0, finalTexture.width, finalTexture.height), 0, 0);

RenderTexture.active = null;
RenderTexture.ReleaseTemporary(rt);

finalTexture.Apply();

GUI.DrawTexture(Rect, finalTexture);

This will give a texture for Eve that has the right color and looks like it has some specular shader applied. Kerbin and Laythe are still screwed up, but in a different way than before. :confused: The other planet textures look no different from the flat diffuse map.

So is there some way to have the normal map applied to the diffuse map? Or does that even work without some 3D mesh to wrap it around and apply a light source to? And any ideas about what makes the Kerbin and Laythe scaled space maps different?

Link to comment
Share on other sites

I am assuming that in order to do this, I would need to access libraries/apis being used. For that I can read and go through your scripts used on RealSolarSystem via Github, awesome that you uploaded it there. And just out of curiosity, how did you figure out how to modify these things in the first place?

Link to comment
Share on other sites

It does. The addon rules prohibit sharing/reusing stuff from KSP_Data (vs. GameData).

Psst! Don't tell anyone, but this rule seems to not work when people share the asset file with modified sun_flare. ;)

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...