Comments (5)
If you're working on a Unity project, a potentially simpler approach might involve utilizing Texture Arrays and either finding a program or a GitHub script that can resize all the images within a folder. Within Unity, you'll then need to create your own Texture Array. This process will require a specific or modified shader, which may also need to support SPS-I (or from Unity Docs) to ensure that rendering behaves as expected on various devices, including the Quest. Additionally, creating a texture array necessitates a script for generating it from your texture files, which you can either find or create yourself. You can utilize the second UV map's X coordinate as an index to determine which texture to use.
Furthermore, you can utilize that program or GitHub script to downscale textures and replace the defaults with them if the file names match. However, you might need to press "File > External Data > Unpack all into files" in Blender first, because the combiner uses packed images, but you'll be editing the actual files.
Typically, to resize materials using the combiner, you can change the size settings in the gear options on a per-material basis. However, with 4000 materials, it would be more efficient to create a small Blender script or command to automate this process.
If you encounter issues with textures not being properly atlased, it might be due to unsupported shaders or incorrect node names. The combiner relies on node names to identify which nodes to use. The easiest approach is to use a Diffuse BSDF node, as it has only one input, and check that its "name
" property is set to "Diffuse BSDF
" without translations. And the Image Texture node has "Image Texture
". You can find the name
property in the Shading tab when you select the node and press the 'N' key to reveal the right-side panel in the nodes window. Information on supported shaders and the expected node names can be found in this script: utils/materials.py.
from material-combiner-addon.
Hey Grim-es! Thank you so much for your response!
Your tool is actually working great if I select a subset of my mesh, but when I select the whole thing I get an error that says the output would be too large. So far, the only option that works is setting the size to custom, but that causes unwanted compression of the textures into one atlas.
I am hoping to automatically pack the textures up to a limit (16384x16384) after which it would start a new atlas, resulting in an output that contains multiple atlases / materials. Is that possible? I started looking through your code to see if there would be an easy modification that basically separates out the textures into multiple atlases after one reaches the maximum 16384x16384, but have not figured it out yet.
Thanks so much,
Ben
from material-combiner-addon.
Implementing atlas separation can be challenging currently, as it uses a basic bin-packing method. Someday it would be great to add more advanced packer(s) that can create multiple bins when the atlas exceeds certain dimensions.
Currently the tool generates one large atlas of unlimited size and then checks to see if it has been exceeded. The maximum allowed size can be changed here. You can then create an atlas (but it has some memory limits and may not work), manually split it into smaller images, and adjust the corresponding UVs. This adjustment involves proportionally scaling the UVs based on the size of the cropped image relative to the overall size of the atlas, and manually adjusting the UVs by calculating the required X and Y coordinates to ensure they are properly centered in the image.
from material-combiner-addon.
Hello again! I found a reasonable workaround for this issue! I wrote a script that iterates through all my meshes combining them in groups of 1024 (which with 512x512 textures on each model, the atlas from each group is a nice 16384x16384 grid). I then toggle on objects each group individually and export out an atlas for each group.
Because I am dealing with massive data sets and each atlas export takes a while, I am wondering if I can add the atlas export to my script? Is there a way call the "save atlas to" function from a script? If so, I could iterate through each of my groups, and save the atlas out!
Here's my script if you are curious:
`import bpy
objCount = 0
parentList = []
#Group objects into parents with no more than 1024 meshes.
#This also removes unwanted empty objects
for obj in bpy.data.objects:
if obj.type == 'MESH':
if(objCount % 1024) == 0:
bpy.ops.object.empty_add(type='PLAIN_AXES')
parent = bpy.context.active_object
parentList.append(parent)
world_loc = obj.matrix_world.to_translation()
obj.parent = parent
obj.matrix_world.translation = world_loc
objCount += 1
bpy.ops.object.select_all(action='DESELECT')
#Join all the models together that contain the same group parent
for parent in parentList:
for child in parent.children:
child.select_set(True)
joiner = parent.children[0]
bpy.context.view_layer.objects.active = joiner
bpy.ops.object.join()
bpy.ops.object.select_all(action='DESELECT')`
from material-combiner-addon.
You can use the following Python command within your script to initiate the atlasing process and specify the folder where the atlased images should be saved:
bpy.ops.smc.combiner('EXEC_DEFAULT', directory='C:/save/directory/path', cats=False)
You can iterate through objects in your scene and selectively hide those that should not be atlased during the current iteration. Objects that are hidden will automatically be excluded from the atlasing process.
from material-combiner-addon.
Related Issues (20)
- Output image size too large, Custom Atlas Size doesn't work. HOT 1
- image has wrong mode HOT 3
- Wont merge more than two materials HOT 1
- UV Mapping not Perfect HOT 2
- Material list not refreshing
- Unfamiliar Traceback error HOT 1
- Materials in imported GLR scene files are incorrectly treated as duplicates HOT 1
- Weird output uv map HOT 2
- Addon Combining duplicate materials when all materials are not duplicatesa
- Combining non-duplicate materials as duplicates in blender 4.0 HOT 3
- how to use this HOT 3
- color must be int or single-element tuple HOT 1
- Add-on wont let me turn it on HOT 2
- Normal atlas generator HOT 1
- output image size is too larg. how to fix it......please HOT 2
- error....output image size is too larg. how to fix it......please HOT 1
- UV's Misaligned with Pixel textures
- I can't merge materials HOT 2
- Traceback error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-combiner-addon.