Skip to content

darthLeviN/godot_custom_vertex_attribute_demo

Repository files navigation

demo on how to use custom vertex attributes for indexing texture arrays for mesh surfaces. related to the godot patch available at : https://github.com/thenegativehunter2/godot/tree/custom_vertex_attribute

steps :

  1. first save your mesh resource so you can modify it.

how to prepare your mesh

  1. attach your script to the new mesh (you can save again if you want to keep it attached, but beware the changes the script makes may also be saved) attach your script

  2. alter the floating point array that was exported via the script to set different indexes for different surfaces how to use

how it works : in the vertex shader there is 4 custom vec4 (4D vector of floating point numbers). you can access them via CUSTOM0, CUSTOM1, CUSTOM2 and CUSTOM3. you can use a MeshDataTool and call the functions like set_vertex_custom with a Color as input to alter the data. then you can commit the changes to the mesh.

the cidx parameter selects from CUSTOM0-3. only one of the parameters (customf and customu) is used. it depends on the data type. if no type is selected the data type will default to RGBA_FLOAT

the get functions (for example get_vertex_custom) can also be used to retrieve the vertex's custom attribute as a Color or a PackedByteArray depending on it's data type.

keep in mind that in godot 4 the option to remove a single surface from an ArrayMesh seems to have been removed so you will need to recommit the entire mesh. even the surfaces you don't alter.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published