Hello. I'm trying to write a shader to display the edges of a model, just like the basic Material Wireframe, but that should work on Android.
I'm getting to something, but the lines are in the middle of the faces, not on the edges. And I'm kind of lost
Looks like you're trying to use barycentric coordinates to determine the pixel distance to edge? In that case .. you're accidentally using the vertex position as edge factor input, while you should be using your barycentric coordinates / vertex colors.
Personally i'm not a huge fan of this approach as it "draws" a line on the inside of a triangle .. resulting in a wireframe that appears thicker on edges that lie in between visible triangles compared to edges that don't.
Oh, thanks. Coloring each triangle with 3 colors was that I was trying to do, but I didn't know I could put a ZExpression inside a Mesh Producers. So I was kind of stuck, wondering if I had to edit the mesh inside blender or something... Your example is really helpful.
I don't seem to find a simple way to draw wireframes in ES2/GL3. I've read about duplicating the 3DS models by suppressing the faces, while keeping the edges. Or using an OpenGL functions to manually draw GL_LINES in between vertices if there is a significative angle for each edge shared by two triangles, but I don't think ES2 has GL_LINES.
Edit:
After reading a bit more, I could simply use geometry shader... Now I'm getting to something
Ats wrote: ↑Mon Oct 13, 2025 10:05 amColoring each triangle with 3 colors was that I was trying to do, but I didn't know I could put a ZExpression inside a Mesh Producers.
It feels like a bit of a hack. Would have been more convenient if there was a way to access mesh data ( vertices & faces ) directly, or if MeshExpression had a VertexIndex property.
Ats wrote: ↑Mon Oct 13, 2025 10:05 amOr using an OpenGL functions to manually draw GL_LINES in between vertices if there is a significative angle for each edge shared by two triangles, but I don't think ES2 has GL_LINES.
All versions of OpenGL ES support GL_LINES, GL_LINE_LOOP and GL_LINE_STRIP.
Ats wrote: ↑Mon Oct 13, 2025 10:05 amAfter reading a bit more, I could simply use geometry shader...
Do keep in mind that Geometry Shaders only work in OpenGL ES 3.2 .. and that they will always be significantly slower compared to using a static mesh.
All versions of OpenGL ES support GL_LINES, GL_LINE_LOOP and GL_LINE_STRIP.
Oh, ok. Reddit is so full of crap
Anyway, I have something that is working a bit like I want. I'm going to try it on Android, to see if it is showing up. And I'll make it better, faster and stronger another day.