-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make AtlasTextures work with SpatialMaterial/3D meshes #1708
Comments
Why is this closed? |
it seems to be the same issue as the sampler2D. |
Well I mean, you are proposing something to be changed/added in Godot. |
ok |
Note something would need to be done about texture repeat for texture atlases |
I have an idea of how it could work. |
I would really like this, though not necessarily for the performance benefits of using AtlasTextures in 2D (if @SIsilicon is right and the only way is to first render to a viewport, that sounds like it may even reduce performance?), but actually just as a workflow QOL thing. It would just be nice to be able to use regions for SpatialMaterials. I do a fair bit of work doing pixel art textures in 3D, and constantly having to split up spritesheets and tileset images into hundreds or thousands of tiny pngs to use in 3D is a bit tiresome and hard to manage sometimes, not to mention sometimes I may only want a section of that tiny png as a surface's material. Obviously this is something that's better suited to something like Blender or GIMP, but it'd be real nice to have an option to do it in Godot just for speed and time efficiency. To have to boot up those programs, locate my file in the filesystem, create slices and selections, UV maps, export into formats, etc, vs just applying the texture as usual in the material/shader and selecting a region, done. Sprite3D allows for the use of a single region in its texture, something like that would be really nice in regular SpatialMaterials, I'm not sure on the implementation details/differences between the two or how applicable that code would be. Edit: In the past where I have nice neat sprites arranged in a grid in a single image, I've created a shader with exact UVs that can take the "custom data" from a MultiMesh to create a 3D "texture atlas" style efficient mesh renderer with a single uniform int for the frame number. It can work great when setup correctly, but it's a bit of a pain to get right and still you're limited to a fixed size rather than just selecting an arbitrary section of a texture to use. Edit2: having slept on it, I have an idea to make an add-on that could use MultiMeshInstance to make an "easy" primitive builder for spritesheets (to quickly build walls and floors in a "ProBuilder" or "Sprytile" kind of style using regions of a spritesheet) using the shader above. I'm going to prototype it and see what happens, and maybe it'll shed some light on a good implementation for the engine, but either way I will publish it to GitHub sooner or later. Unfortunately it'll be Mono C# only at first as I don't know GDScript all that well. |
I recently ran into this myself while playing about with 2D scenes, in Godot 4.0.2. I was expecting the I think having a toggle option for whether or not Based on the issue name, I'm conflicted whether or not to post here or open a new proposal. While searching through related issues, much of them seem to link back here directly or indirectly. So hopefully this isn't off-topic or against the rules, and provides more data/justification on the scope of the proposal... |
Oh damn, I was wondering why this was not working 😢 I can thankfully play around with the UV values for my grid map version but this is really strange to see. Anyone working on this? |
The way I fixed this was just creating meshes in a GridMap using a UV on a So you take any mesh, and want to apply an Atlas texture to it in a single plane (easier). You can send in a func make_atlas_materials(
mesh: Mesh,
uv_position: Vector2,
uv_scale: Vector2,
) -> Mesh:
var to_set: StandardMaterial3D
var to_return := mesh.duplicate(true)
for idx in range(to_return.get_surface_count()):
to_set = to_return.surface_get_material(idx).duplicate(true)
to_set.albedo_texture = self.get_texture()
to_set.set_cull_mode(BaseMaterial3D.CullMode.CULL_DISABLED)
to_set.set_uv1_scale(Vector3(uv_scale.x, uv_scale.y, 1.0))
to_set.set_uv1_offset(Vector3(uv_position.x, uv_position.y, 0.0))
to_return.surface_set_material(idx, to_set)
return to_return |
Describe the project you are working on:
3d rouge like
Describe the problem or limitation you are having in your project:
I have a image which I want to swap out later for dungeon variation.
however it seems like texture atlas doesn't work with albedo in spatial shaders.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
I suggest all types of texture work for 3d objects.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
I guarantee this would be used and while it can be worked around with shaders or uvs its not ideal and seems kinda like a bug.
Is there a reason why this should be core and not an add-on in the asset library?:
normal textures work why can't other textures?
The text was updated successfully, but these errors were encountered: