Moo-Ack-Productions / MCprep

Blender python addon to increase workflow for creating minecraft renders and animations
https://theduckcow.com/MCprep
GNU General Public License v3.0
283 stars 26 forks source link

Optimizer Improvements #311

Closed StandingPadAnimations closed 11 months ago

StandingPadAnimations commented 2 years ago

Opening this to keep track of the improvements I'm thinking of adding to the optimizer (though these are mostly ideas). I'll open a pull request once the next version of MCprep (which I assume is 3.4.0) is released

So far my ideas are:

I think I'll work from simple to difficult and see how it goes

TheDuckCow commented 2 years ago

Sounds good @StandingPadAnimations - I would recommend a couple practical points for development progress:

As for some specific points or ideas on the optimizations above:

StandingPadAnimations commented 2 years ago

For light bounces, I was thinking of using variables like "True glossy" and "JSON glossy" and then averaging them out if they're both different and if we're dealing with PBR materials. JSON glossy would be using the JSON file and True glossy would be based on if a material has a specular map and the JSON file.

For volumetrics, it's easier as we're simply adjusting the stepping rate. It would start at something like 5, and then for every volume node without a texture controlling the density we'll increase by 2. For any volume node with a texture, we'll decrease by 2 (basically tug-of-war but with volumetrics). I was also thinking of something similar for automatic scrambling distance but with things it doesn't like dealing with (such as volumetrics)

StandingPadAnimations commented 2 years ago

"True Glossy" and "True Transmissive" counters have been replaced with a system of "if the value is the default set by MCprep, then simply don't count it. If it uses a map, then count it"

StandingPadAnimations commented 2 years ago

One more thing I want to add to the list: reusing already existing materials

I've noticed that when MCprep preps materials, it creates duplicates. Currently the optimizer deals with this by purging orphan data, but it would be simpler to just reuse existing materials during the prepping process

Of course, this is less of an optimizer thing and more of a prepping thing

TheDuckCow commented 2 years ago

Under what circumstances is prep materials making duplicates? Hm that doesn't sound right, should modify existing materials. May be worth looking into how to resolve this directly. Also be aware of the combine materials feature that already exists, could be that optimizer calls this, but it can also have unintended consequences (eg if you swap skins but don't rename the material. Hm maybe swap skins SHOULD attempt to rename the material idk)On Jul 2, 2022 3:50 PM, StandingPad @.***> wrote: One more thing I want to add to the list: reusing already existing materials I've noticed that when MCprep preps materials, it creates duplicates. Currently the optimizer deals with this by purging orphan data, but it would be simpler to just reuse existing materials during the prepping process Of course, this is less of an optimizer thing and more of a prepping thing

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

StandingPadAnimations commented 2 years ago

Prep materials seems to make duplicates whenever I import a new OBJ or even the same OBJ. Here's what I mean:

  1. I import the OBJ once image

  2. I import the same OBJ and prep. Despite combine materials being enabled (btw, I'm curious as to why it's disabled by default), all the materials are indexed and I see both duplicates. The optimizer gets around this by purging orphan data twice (which is the amount of times needed to remove duplicate materials) but it's 2 extra calls that have to be done image image image

In particular, it's annoying when I do a quick change to something, reimport the same OBJ and have to set up stuff like water shaders (which is made more annoying when the optimizer purges orphan data)

StandingPadAnimations commented 2 years ago

I'll be looking into enabling Fast GI for the next update. The main reason it's not used right now is because I'm not sure if it impacts scenes too much. I'll have to do some tests to see how it compares and if it's a good tradeoff

What I'll likely do is enable Fast GI for CPU/OpenCL users by default and make it optional

StandingPadAnimations commented 2 years ago

One other change I might do is actually not mess with caustics for Blender 3.0+. In Blender 3.0 it seems like caustics have been improved performance wise, and they have a benefit with reflective and refractive materials.

As such, it just makes sense to not mess with caustics settings, but again this will require some testing on my end.

I've been watching a video on Cycles optimization and it seems like Cycles X changed a few things, so expect some differences for 3.0+

TheDuckCow commented 2 years ago

Ah yes, importing new obj's is just using blenders OBJ importer which indeed itself will generate new materials. It's actually an interesting idea that we could specifically look at only the newly generated materials during import, and seek to replace those with prior matching generalized names pre import. I don't have combine mats on by default because there can be artifacts, namely for the reason I mentioned where if you select everything and happen to have rigs there with different skins applied, you can accidentally merge two intentionally different materials together. That too probably could be made smarter to dub dub checks between two materials to be merged to see if they have the same source image name (even if the path is different.. since it could be the copied MCprep resource pack vs the original export next to the obj).Indeed data would be cleaned up after opening and reloading blender. I don't purge right away as the user may not be expecting that to happen and they have have other materials or unused data they aren't expecting to lose. If we do include that, there should be a warning at least or a way to skip the purge part.On Jul 2, 2022 4:41 PM, StandingPad @.***> wrote: Prep materials seems to make duplicates whenever I import a new OBJ or even the same OBJ. Here's what I mean:

I import the OBJ once

I import the same OBJ and prep. Despite combine materials being enabled (btw, I'm curious as to why it's disabled by default), all the materials are indexed and I see both duplicates. The optimizer gets around this by purging orphan data twice (which is the amount of times needed to remove duplicate materials) but it's 2 extra calls that have to be done

In particular, it's annoying when I do a quick change to something, reimport the same OBJ and have to set up stuff like water shaders (which is made more annoying when the optimizer purges orphan data)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

StandingPadAnimations commented 11 months ago

Closing as not planned