jensjeflensje / minecraft_imagery

Toolkit for taking pictures and videos in Minecraft
https://www.spigotmc.org/resources/imageryapi-take-pictures-in-minecraft.111347/
MIT License
18 stars 4 forks source link

Transparent Water #5

Open kuraiskrap opened 2 months ago

kuraiskrap commented 2 months ago

Would it be possible to edit RGB values for underwater blocks to allow transparency? something like on hit of water, raytrace again ignoring water?

my quick and dirty proof of concept code was this set {_r} to {_r} 0.5 set {_g} to {_g} 0.7 set {_b} to {_b} + 100 if {_b} is more than 255: set {_b} to 255 but it let me see differences between sand, clay and dirt (image is only 64x64 and has a heavy noise filter) image was not taken using imageryAPI, but much slower concept skript image

jensjeflensje commented 2 months ago

Hi kuraiskrap, we already do this for translucent blocks (like glass, cobwebs, iron bars and such). You can view the configured translucent blocks here: https://github.com/jensjeflensje/minecraft_imagery/blob/374732c2759fadd9919ffe8b680bba08deb03b74/src/main/java/dev/jensderuiter/minecraft_imagery/Constants.java#L72 It's calculated somewhat similarly to your script, by using a TranslucentBlock's dye and applying that with a certain factor. https://github.com/jensjeflensje/minecraft_imagery/blob/374732c2759fadd9919ffe8b680bba08deb03b74/src/main/java/dev/jensderuiter/minecraft_imagery/image/ImageCapture.java#L130-L142

I understand why you would want the same for water, but I'm unsure if this should be done by default, as it will probably decrease performance. It could be implemented by making the list of translucent blocks configurable.

Would you be open to contributing? Given the fact that you seem to be doing some experiments of your own :)

kuraiskrap commented 2 months ago

unfortunately my java knowledge is.... untouched since a starter course like 11 or 12 years ago I've really only familiar with skript at this point, super happy you support it :)

if i knew java id try and contribute, was helping with the other camera skript

currently my idea is to take your map outputs and maybe edit it with a skript to add noise or something after or redo just the water to add the transparency (you have no idea how much faster your code is)

jensjeflensje commented 2 months ago

I don't think you'll get good results from that and it does sound somewhat... inefficient. If I have time, I can add the list of translucent blocks to the config, like how the block color palette currently works. That would allow you to make the water translucent yourself (and tweak any other translucency settings). I'm just not sure if that's going to be very soon 😅

kuraiskrap commented 1 month ago

managed to get a proof of concept working on my fork https://github.com/kuraiskrap/minecraft_imagery

water has transparency values of 0 0 0, so it makes no difference dye wise it flips a flag when it hits water for the next raytrace to ignore fluids (technically causes issues with water over lava) it then applies the RGB value changes i mentioned to the pixel avoiding the dye system i don't fully understand

I wouldn't necessarily use my code, sometimes a photo fails due to color being null but idk java, so it was basicly using my basic knowledge and chatGPT to put something together changing the adjustment values would also be worthwhile since my values were a guess that worked well enough

image image

jensjeflensje commented 1 month ago

Thanks for your experiments! I'll take a look at your fork to see how I can use this to actually integrate it into the library.

ConnorBP commented 3 weeks ago

how about having the distance from the first water hit to the final depth hit contribute to a darker dye. This information is already available if you run a second ray under water and will increase the fidelity quite a bit