jasonjgardner / jg-rtx

Minecraft v1.21 HD PBR resource pack. Works with Java and Bedrock shaders.
Creative Commons Attribution Share Alike 4.0 International
114 stars 5 forks source link

Glass transparency #23

Closed jasonjgardner closed 3 years ago

jasonjgardner commented 3 years ago

PNG glass textures appear more opaque than TGA texture files:

Broken glass

erich666 commented 3 years ago

Bug should be reported to Mojang, if confirmed

See https://github.com/jasonjgardner/jg-rtx/discussions/18#discussioncomment-545128 - the conversion process is perhaps part of the problem?

jasonjgardner commented 3 years ago

You're right about the file formats. You might notice that I just pushed a couple commits with TGAs. I should have read the discussions first!

Yes, I think the real issue is my misunderstanding of the shader settings in Substance Painter – and in general. Did I mention I'm new to this? I believe the difference is in the IOR...?

Thank you for looking into that issue. Sorry, it was my mistake!

erich666 commented 3 years ago

No worries at all! I'm glad to hear it's probably just user error - that makes way more sense to me than that TGAs work, PNGs don't (always still possible, but I'd want to figure out why). I do hope PNGs work out for you for all files - TGAs really have spotty support. For example, the extremely popular Irfanview program does not properly read them and export to PNG.

Me, I bit the bullet yesterday and added TGA support to my tools for Mineways. Took about 5 hours, but it's done. Others use TGA's, too (all due to that one line of advice about "use TGA, not PNG" in the MinecraftRTX documentation, which was there only because some unknown tool they were using was misbehaving).

jasonjgardner commented 3 years ago

So I've investigated this further.

File formats

Yeah, that was user error/misunderstanding. I thought the MDL parameters in Substance Painter's IRay rendering had some affect on the texture set output. I adjusted the texture's glass opacity to look better in the IRay render. But the refraction and IOR setting are for the render, not for the texture.

Substance Painter IRay render

Then I probably tried the texture in Minecraft and noticed it was wrong. Then tried TGA output, so I could adjust the alpha channel in Photoshop. Then was like "WTF?" Then eventually "Maybe that's how it's supposed to be?" and released it anyway.

Glass transparency

Per our other disucssion: Seems to me that glass in Minecraft w/ RTX isn't as permeable as one might expect. The raytracing creates a strong glare. Here's what gives me that impression:

Medieval RTX example glass Medieval RTX example 2 Glare in Medieval RTX world (and other packs/worlds) is hard to see through without a light source behind it in daylight.

Smooth example Rough example Adjusting roughness decreases glare but doesn't look right.

Dark room example Can't see into a dark room with smooth textures

ARGB example Glass which has been created using ARGB values in the texture set. No potential file format compression to interfere with opacity.

The last example is at 50% opacity and it's not bad. (Still some glare though.) Which made me realize what was going on with my glass textures. Just set the opacity and let the glass look glassy.

P.S.

Compressed PNGs gone awry There is one caveat with PNG. Be delicate with compression.

erich666 commented 3 years ago

Thanks for researching and untangling this! About my only conclusion from all this (other than "really, TGA vs. PNG indeed doesn't matter," though I still think there's some PNG tool out there that's misbehaving and that caused the initial confusion) is that "good-looking glass is hard." I'm hoping you solve it to your satisfaction in MinecraftRTX. Me, I'm trying to get things looking good in Omniverse, so whatever you set is what I'll try to emulate on my side. When you're satisfied on your end, I'll start adjusting MDL files on my end.

And, that's weird with PNG compression, I've never seen that - how did you get that strangeness? I use PNG Crush to losslessly squish textures, which knocks a few percent off the size of the files I distribute.

jasonjgardner commented 3 years ago

That compression funkiness is from PNG Gauntlet. The compression settings were too aggressive. I've been using OptiPNG and imagemin in the build scripts I've been using. They seem to work pretty well.

erich666 commented 3 years ago

Ah, cool, I hadn't heard of OptiPNG; I should try it vs. PNG Crush and see how it goes.

Actually, I just did now. It looks like PNG Crush gives a smaller PNG in three of five test cases (images ranging in size from 0.5 Mb to 55 Mb, consisting of your textures in big mosaics). The saving are not large percentage differences, but PNG Crush is generally better, ranging from 40k to 138k fewer bytes. The two smaller files, where OptiPNG gave smaller sizes after compression, the savings were 4k and 5k. Funny that they would differ in this way. Either one is better than not compressing at all. YMMV.

erich666 commented 3 years ago

By the way, looking into a window from the outside is kind of hard:

image

The reflection factor should be pretty low when you're looking straight on at a window, just a few percent - most of the contribution comes from light refracted through the window. But, if there's little light coming from inside the house, then the reflection of the sky will dominate.