Star Ruler 2

Star Ruler 2

Your stars. Your rules.
Create and submit Mods (such as Maps, New Subsystems, Scenarios, and even Total Conversions) for others to download and play with Star Ruler 2's seamless workshop integration.
Learn More
dolynick 11 29 Aug, 2016 @ 7:23pm
PBR Shaders for Shipset Modders
For some time now Jon Micheleesen (one of the developers for SR2) has been planning on adding a modder-friendly version of a PBR shader for use by the community. The stock ship models in the game use this style of shader already but modded shipsets are pretty much exclusively limited to non-PBR methods due to difficulty and the ogex file format requirement. These required a new custom set of shaders to enable PBR features on standard obj models.

Jon has been working on these for some time now and while he would ultimately like to patch these shaders directly into the game, for now he has opted to release prelimiary versions of them to the community. To help distribute them and make them available to the community, I have offered to bundle them into the DOF Shipset Common Library which is already intended to be a shipset modder community resource.

The shaders also include support for:
-Visual damage effects on ships.
-Shield effect panels on ships.
-Variable thruster color based on current ship acceleration.
-Limited multi-texture support (one additional texture file if useful).

If you are interested in accessing them, you can find the DOF Shipset Common Library here:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=505348416

I have also written a very basic (so far) guide on how to use them here:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=754714490

I personally find this development to be exciting for our game community and I look forward to seeing what people can do with them. Here's a screenshot of what happened when I applied the new shaders to a ship model I had been working on:

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=754062410

Finally... A big "Thank You!" to Jon M for donating his time to make this happen for us.
Last edited by dolynick; 29 Aug, 2016 @ 7:37pm
< >
Showing 1-10 of 10 comments
Thats its really impressive.
vaaish 3 30 Aug, 2016 @ 1:44pm 
Yes quite. I'm rather looking forward to seeing more of this.
dolynick 11 30 Aug, 2016 @ 5:54pm 
Today I discovered that my version of Photoshop doesn't actually save PNG files with alpha/transperency. So that screenshot is actually the exact same texture set as in this image:

http://www.olynick.net/sr2/images/hiigaran-patchy.jpg

The only difference is that it's using the PBRModShipS shader with default (missing, so white fill) alpha channels. The only new texture layer in effect is Roughness and it had the Albedo saturation/lightness adjustment applied.

(Roughly the same view)
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=754048344

That should illustrate the difference in visual effect between the old non-PBR shaders and the new PBR shader.
Last edited by dolynick; 30 Aug, 2016 @ 5:56pm
jonmicheelsen 1 31 Aug, 2016 @ 11:38am 
png ignores what's in the alpha LAYER. You need to apply it as a LAYER MASK and apply the layer mask (as premultiplied alpha) It's the only way you can get alpha in a png.
Dalo Lorn 23 31 Aug, 2016 @ 12:11pm 
That's... not true, in my experience. PNG files export with alpha just fine, at least in GIMP.

(Proof: Every time I committed an image to ABEM's GitHub repository, it was a PNG made in GIMP without any tinkering with the settings. Lots of alpha there.)
dolynick 11 31 Aug, 2016 @ 1:56pm 
Originally posted by Dalo Lorn:
That's... not true, in my experience. PNG files export with alpha just fine, at least in GIMP.

(Proof: Every time I committed an image to ABEM's GitHub repository, it was a PNG made in GIMP without any tinkering with the settings. Lots of alpha there.)

He's not talking about basic transparency. That works just fine and I've had no problems making PNGs with clear bits in PS CS5 either.

He's talking about an actual alpha layer, which translates into transparency when saved with it included in the PNG. You cannot save a PNG with a discreet alpha channel. I'll see if I can get an image slapped together to demonstrate.
Last edited by dolynick; 31 Aug, 2016 @ 2:00pm
jonmicheelsen 1 31 Aug, 2016 @ 2:21pm 
Exactly
dolynick 11 31 Aug, 2016 @ 3:08pm 
Ok. Here's an illustrated example of the issue. I hope it clears things up.

http://www.olynick.net/sr2/images/png/png-cs5-alpha.jpg
The image on the left was saved using the default CS5 PNG format with an alpha channel in place. The black in the alpha channel should be 100 transparent, the white 100% solid - so the blue circle should have a hole in the middle. On the right is the saved image re-opened. As you can see, the saved PNG has discarded the alpha layer data and there is no change to the blue circle.

http://www.olynick.net/sr2/images/png/png-cs5-alphamask.jpg
Here, on the left, the alpha channel is instead applied as a mask directly to the layer (instead of as an alpha channel). On the right is the image re-opened. The mask for the hole has been preserved as the equivalent of alpha channel data.

I believe the above is what Jon was suggesting when he says you need a layer mask. It's a bit clumbsy to my mind but works.

The solution I've been using is to download a photoshop plug-in for PNG format. In my case I went with SuperPNG ( http://fnordware.com/superpng/ ) but any plug-in with the necessary functionality will do.

This is the results with a SuperPNG with Alpha 1 preserved:
http://www.olynick.net/sr2/images/png/png-superpng-alpha.jpg
I had to add the white background because SuperPNG did some odd stuff with the standard transparency/empty space when also using the alpha channel. On the right though you can see that the alpha channel data was preserved in the re-opened image. It should be essentially the same result as Jon's mask layer method, only I personally easier (less chance of confusion) to use the alpha channel. Just don't use the "Clean Transparency" checkbox... bad things will happen in game.

The other thing about SuperPNG is that it offers control over the compression of the PNG file. This is something that we haven't discussed here yet but I have with Jon. By default Photoshop uses roughly the equivalent of SuperPNG's max compression ("Smaller files"). The game has to decompress all PNG files when it loads them into memory and this has a computation time cost. When someone says they're seeing "white boxes" that slowly fill in when the game starts, this is because those white boxes are placeholders while the engine decompresses the image and gets it into memory. With uncompressed PNGs, there shouldn't be any decompression time so things should load significantly faster, although it will depend on how much compressed PNG data is in the loaded mods. Techincally, there is a good chance that compress/decompress routine is losing some data as well (probably some red and blue channel data, according to Jon), so it should be higher fidelity too (although you may not notice). The trade-off is that the uncompressed PNG files are often about x3 as large in filesize so the mod will be larger in filesize to download and store.

I don't know what GIMP offers for options for saving PNG files, but it's possible that it has compression and alpha layer preservation options built in.

If this post is clear enough that it makes sense to everyone reading, then I will probably add the above to a new section of the Shader Guide that covers it. I'm sure Jon will correct me if I mis-termed anything or got it wrong.

I should also note that having to use the alpha layer means that your saved PNG is going to have semi-transparency over most of the diffuse/color data once you save it. I haven't figured out a way to undo this, so it means that editing the PNG can be difficult after the fact. So far, I end up keeping a "master file" PSD for the image and then export a completed PNG version just for game use when I'm done. If I need to make changes, I go back to the PSD and then re-export the new game PNG version when done.
Last edited by dolynick; 31 Aug, 2016 @ 3:24pm
Lucas  [developer] 2 31 Aug, 2016 @ 4:22pm 
With uncompressed PNGs, there shouldn't be any decompression time so things should load significantly faster,

Hold on for a second here. When it comes to these types of things you can never tell without doing actual real-situation profiling, but speaking in general terms disk IO is quite significantly more expensive than cpu number crunching. Loading time wise I would definitely expect a smaller, compressed, png to load much faster than a larger one because of that.
dolynick 11 31 Aug, 2016 @ 6:58pm 
Hold on for a second here. When it comes to these types of things you can never tell without doing actual real-situation profiling, but speaking in general terms disk IO is quite significantly more expensive than cpu number crunching. Loading time wise I would definitely expect a smaller, compressed, png to load much faster than a larger one because of that.

That's a good point Lucas. Maybe I'm getting a bit ahead of myself here and looking at it in too much of a vacuum. I haven't been able to do a proper test yet to see what the difference might turn out to be. A few files isn't going to tell me anything conclusive and I haven't yet got a large quantity of files set up to judge the impact. I suppose it would also depend on the disk in question, there might be more benefit on a fast SSD but more of a penalty on a slower HDD. I thought it at least warrented a mention though - floating it for discussion and consideration, if you will.

My current project has been done uncompressed so far but is well under half done yet. I may have to actually do a couple shipsets to get a clear picture. My game files and mods for play are all hosted on a Samsung 850 Pro, so I might see a net benefit or I might not. I'll also say that saving an uncompressed PNG file to my HDD work space (4TB 7200 rpm) is considerably faster than saving a compressed one (either SuperPNG or PS PNG) but doesn't account for a non-seqential diskspace or extensive use scenario. Opening also seems marginally faster with uncompressed but it's a much smaller difference.
Last edited by dolynick; 31 Aug, 2016 @ 7:13pm
< >
Showing 1-10 of 10 comments
Per page: 1530 50