Ludeon Forums

Ludeon Forums

  • August 11, 2022, 01:56:31 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [Fixed!] Imported snow replacement texture looks grey instead of white ingame  (Read 1092 times)

Moogie

  • Drifter
  • **
  • Posts: 22
  • Refugee
    • View Profile

Please excuse the toxic haze... Yeah, my colony is kinda in the middle of a thing at the moment.



I'm not sure what I'm doing wrong. First off, importing the texture into the resources.asset archive appears to be the only way to modify snow. Believe me, I've tried it the normal way--the game just ignores the files if you try to make a mod out of it. And while I've technically been able to import the texture, it doesn't appear right ingame.

I've used the PSD that comes with the art source zip that's floating around these forums as a base. As far as I can tell, my masking etc is identical.




The white of the snowflakes is 100% white and 100% opaque in the middle, with feathered edges.

I had to do the same thing for the snow ground texture, but that one turned out fine. Mostly. There are seams, but that is 100% the game's fault. My textures are seamless.



In any event, if that worked, why does the falling snow overlay not? My only guess at the moment is that I would need to edit the Material of it, but UABE cannot export .mat files into a readable/editable format. Have I hit a dead end, or is there something that I'm missing?
« Last Edit: April 02, 2020, 01:28:38 PM by Moogie »
Logged

JT

  • Colonist
  • ***
  • Posts: 136
  • Big Whoop
    • View Profile
Re: Imported snow replacement texture looks grey instead of white ingame
« Reply #1 on: April 01, 2020, 08:04:04 PM »

A lot of the weather stuff is indeed hard-coded to use Unity assets instead of external files -- take a look at your favourite IL decompiler at Weather or Snow for instance, and you'll see that the particles are all loaded as Unity materials rather than loaded as Texture2Ds from mod data (which would enable easy modding).  That said, it wouldn't be completely unapproachable to make a mod with an assembly that simply edits the Material contained in the target reference class, since even though they are private accessible, you could always use Harmony to replace them with a runtime-generated Material of your choice.  For example, the vanilla RimWorld snow gentle weather is:

Code: [Select]
[StaticConstructorOnStartup]
public class WeatherOverlay_SnowGentle : SkyOverlay
{
private static readonly Material SnowGentleOverlayWorld = MatLoader.LoadMat("Weather/SnowOverlayWorld");

public WeatherOverlay_SnowGentle()
{
worldOverlayMat = SnowGentleOverlayWorld;
worldOverlayPanSpeed1 = 0.002f;
worldPanDir1 = new Vector2(-0.25f, -1f);
worldPanDir1.Normalize();
worldOverlayPanSpeed2 = 0.003f;
worldPanDir2 = new Vector2(-0.24f, -1f);
worldPanDir2.Normalize();
}
}

You could Harmony-postfix the WeatherOverlay_SnowGentle constructor (see "Target method annotations" on the Github page for how to target a constructor) by overriding the worldOverlayMat with a newly generated Material of your own.  Since Unity is really really big on its WYSIWYG editor and assorted nonsense, a simple operation like loading a PNG from the disk at runtime, converting it to a texture, and popping it into SetTexture() as byte data, is absurdly difficult compared to most games -- but still should be doable.
« Last Edit: April 01, 2020, 08:06:53 PM by JT »
Logged

Moogie

  • Drifter
  • **
  • Posts: 22
  • Refugee
    • View Profile
Re: Imported snow replacement texture looks grey instead of white ingame
« Reply #2 on: April 01, 2020, 10:34:01 PM »

While I have dabbled in making a couple of assembly mods, what you describe sounds far above my level of ability. I struggle enough with XPaths. I would be happy enough to just be able to export and reimport the .mat file from the resources.assets like I can do already with the texture.

I will keep looking for a solution, but thank you for the information! It might come in useful. Maybe not to me, but surely to somebody with a suitable education. ;D
Logged

Moogie

  • Drifter
  • **
  • Posts: 22
  • Refugee
    • View Profile

Turns out, sometimes the simplest solution is the best. :)



So, while UABE doesn't have a proper Material plugin, apparently you can just "export dump", edit the values, and then "import dump".

I had just assumed that the dump it created was some useless .txt report of the data, because well... that's exactly what it looks like. And the creator of UABE himself said that exporting Materials wasn't possible because the shaders are baked in as raw byte data, or somesuch.

But lo and behold, editing that .txt file and then reimporting it works like magic!

And I can still make a mod out of this; it will just have to be a UABE patch file. There's an option to create an .exe patcher too but there's no way I'm asking people to forget their basic internet safety 101. :) Also, this snow texture isn't final. Looks a bit too bright now. But I can tweak it until it's better.

Finally, snow that isn't just a field of dead pixels moving across the screen...
« Last Edit: April 02, 2020, 01:35:50 PM by Moogie »
Logged

LWM

  • Planetologist
  • ****
  • Posts: 1083
  • Little White Mouse
    • View Profile

Is a UABE patch file something a player will have to do to change things?  Or does it happen automatically like the other patches?
Logged

Moogie

  • Drifter
  • **
  • Posts: 22
  • Refugee
    • View Profile

The player would need to download the UABE utility and load the patch into it. UABE is a standalone app, though, not something you have to install. So while it's not ideal, it's still a viable solution.

Because it directly modifies the resources.assets file, players would need to be sure to back up that file before running the patch, because there's no uninstaller for something like this.

Tweaked values in motion (may be a little too dim now):


(Larger, bigger filesize version viewable here)
Logged

LWM

  • Planetologist
  • ****
  • Posts: 1083
  • Little White Mouse
    • View Profile

I was going to suggest you look around for someone who could do a Harmony patch, if you're not up for it.
Logged

Moogie

  • Drifter
  • **
  • Posts: 22
  • Refugee
    • View Profile

I'm willing if they are! :) I don't know anybody though, I've never really interacted with the community before I started tinkering.

Some tweaks to opacity have made snow less blinding and much more pleasant to look at now. I'm still debating whether to reduce the number of particles; I think I should also be able to use separate textures for gentle snow vs heavy (because they're currently the same effect).

Some clips (note: my game's a bit dark right now... volcanic winter... not as terrible as toxic fallout, though, for someone living in the middle of a desert):

https://streamable.com/wvtlm8
https://streamable.com/4fj2lf
https://streamable.com/sxzsz6
https://streamable.com/5jbs79
Logged

LWM

  • Planetologist
  • ****
  • Posts: 1083
  • Little White Mouse
    • View Profile

I do like the snow!  I think I might see if I can manage some harmony patches to make this work.

You said you thought a lighter snow might need a different overlay - that seems reasonable.  Will you be able to put that together too?
Logged

Moogie

  • Drifter
  • **
  • Posts: 22
  • Refugee
    • View Profile

Thank you! And yeah, I can for sure create the assets. As for how the game picks an effect for the weather type, I think that's something a patch operation can take care of? In which case, I should be capable of that without any problems. I'll look into it.
« Last Edit: April 11, 2020, 02:19:30 PM by Moogie »
Logged