#Making meshlib meshes transparent to be able to see-through them

12 messages · Page 1 of 1 (latest)

spiral niche
#

Hi, I have a 3D project with a Gridmap set up. I made the meshes in Blender and added the textures there, they are basically floors and walls. I would like to know if there is any way to apply some filter in them to toggle their textures on/off.

As in, in some cases I will want all the tiles to be meshes, and in other cases I might want to disable the visibility of some of them/or their faces (while keeping their collision shape and the visibility of the other meshes).

Is this possible? Is there any shader/material I can toggle on/off to allow this?

I can apply a shader to the meshes by doing:

shader_type spatial;

void fragment() {
    ALPHA= 0.0;
}

To turn them completely transparent, but I'm not sure how to apply it to the specific meshes inside the grid.

wraith vale
#

I'm not familiar with grid maps, but if each mesh that you want to toggle its visibility is a separate node, you can (1) create a uniform variable called "transparency" or something and then (2) set it via code on each one.

See: https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/shading_language.html#uniforms

spiral niche
#

Hey, thanks! I think I can apply the invisibility shader to the mesh. The problem is that I'm not sure how to get the mesh from the gridmap. As doing: gridmap.get_meshes() returns a weird result that I don't really understand.

#

Eg of what get_meshes() returns:

[[X: (1, 0, 0), Y: (0, 1, 0), Z: (0, 0, 1), O: (1, 1, 1)], <ArrayMesh#-9223372009826679636>, [X: (1, 0, 0), Y: (0, 1, 0), Z: (0, 0, 1), O: (1, 1, 3)], <ArrayMesh#-9223372009826679636>,...]
#

It's not really returning the MeshInstance3D of the Meshlib but the actual meshes.

wraith vale
#

The ArrayMesh inherits from Mesh, so you should be able to get the material from it/edit it.

If you had a MeshInstance3D , how would you get/edit its shader or material?

#

(the other stuff in the array you get there is the transform of each mesh in the grid)

spiral niche
#

Looks like MeshInstance3D has a surface material override. Looks like I can't modify the materials from the MeshArray through the Editor, so I would expect it's not possible either through the code.

wraith vale
#

I expect it should be possible given this description from the docs:

GridMaps use a MeshLibrary which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.

If each tile stores both the mesh & materials, I'd think you can selectively change that

#

This page does state this caveat:

Only the materials from within the meshes are used when generating the mesh library. Materials set on the node will be ignored.

https://docs.godotengine.org/en/stable/tutorials/3d/using_gridmaps.html#materials

spiral niche
#

Gonna try then! Thanks!

#

It worked, thanks!