This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Wireframe Generator for Godot (C# + Shader source in thread)

novaleafnovaleaf Posts: 83Member

Had help from cybereality on how to do this.

If you want to see a brief overview video:

Video outlines the features of the Wireframe shader I made. It took about 7 days.

Source code and test scene here: https://github.com/jasonswearingen/godot-csharp-tech/tree/dev/demo-projects/scratch/demos/WireframeMeshDemo but you will probably want to copy/paste to your own project.

Adding wireframes takes to parts: pre-processing your mesh with the MeshDataTool and then a shader that can read the data it encodes into the vertex color.

The MeshDataTool processing is done in WireframeMeshDemo.cs and I did my best to comment the code. I ended up using 5 color channels for vertex ID's, and 1 channel to hint what side is longest (for interrior edge removal). I was able to have these 6 channels by encoding 5 choices into red (20% each) and 1 into green. The shader reads this encoded data and generates the barycentric coords for the rest of the shader to use. The shader is in WireframeMeshDemo.shader

If you have any questions, just ask.


Tags :

Comments

Sign In or Register to comment.