FrancoisRecisio
Topic Author
Posts: 15
Joined: 06 Nov 2023, 12:07

Add custom VGLPaint type

16 Dec 2025, 12:04

Hello,
I want to create a text with a custom brush, and I would need to add information in the vertices (for example replace the color alpha vertex with a custom value).
I know it's probably a lot of work, but I don't see how else to do what I want, with the constraints I have (each glyph can have different custom values). Originally I had thought of using several TextRuns with different brushes, but it poses other problems (like the stroke of the previous run which is in front of the foreground of the next run).
I don't know exactly where the glyphs are triangulated, but I have the impression that to succeed in this, I would have to add an additional type dedicated to the VGLPaint, as well as modify the shader vertices accordingly...
(Since this concerns the source code, I don't know if discussing it on the forum is allowed or not)
Thanks!
 
FrancoisRecisio
Topic Author
Posts: 15
Joined: 06 Nov 2023, 12:07

Re: Add custom VGLPaint type

16 Dec 2025, 12:49

I just found VGLContext::SetLifetime, this is an interesting example
 
FrancoisRecisio
Topic Author
Posts: 15
Joined: 06 Nov 2023, 12:07

Re: Add custom VGLPaint type

16 Dec 2025, 17:41

I'm replying to myself, but I think I have found a solution by analyzing the code in VGLContext::SetLifetime, sorry! If needed, I will continue posting here :) maybe even with the result
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: Add custom VGLPaint type

17 Dec 2025, 00:19

Yes, of course! Happy to discuss your scenario here.

Implementing your own VGLPaint type is not trivial and I wouldn’t recommend diving into it without fully understanding your use case. Have you considered implementing a custom brush shader instead? That might achieve what you want without modifying the core triangulation or vertex structures.

By the way, SetLifetime is checking the license, but I’m not sure how that relates to your original problem.
 
FrancoisRecisio
Topic Author
Posts: 15
Joined: 06 Nov 2023, 12:07

Re: Add custom VGLPaint type

26 Jan 2026, 16:07

Yes SetLifetime isn't a solution, but it gave me a simple example to understand how text drawing works... I found a workaround by using the FormattedText class directly, combined with a custom brush shader.
My main problem was that I needed to change the brush for each syllable of text, so I had to use different Runs with different brushes. But the N runs had their strokes drawn on top of the N-1 runs. I found the solution by adding a second loop in VGLContext::DrawTextLayout : first, I draw all the backgrounds and foregrounds, then all the strokes.

Still, I would really like to be able to use the vertex color buffer in a custom brush shader. Not necessarily for text, but for geometry (or a mesh, whatever). I am somewhat limited because I can only use UVs or the content buffer to send information to the shader. Let's say I have 20 shapes with the same custom brush shader. If I want to send "fixed" values so that the shader reacts a little differently for each shapes, I have to create 20 instances of the brush shader, and I cannot take advantage of batching. Also, I can't really play with gradients written in the vertex color, which could be useful for complex shapes, or where a radial or linear gradient is not enough.

Do you think it would be trivial to overwrite the vertex color buffer, at least for MeshData? I can easily add this to my custom version of Noesis, but if you have any ideas on how to do it properly, I'm all ears!
 
FrancoisRecisio
Topic Author
Posts: 15
Joined: 06 Nov 2023, 12:07

Re: Add custom VGLPaint type

26 Jan 2026, 16:09

Without necessarily using the vertex color buffer, I could also have an additional buffer in each vertex, it doesn't matter. As long as I can write more information into a vertex than I can read in the shader.
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: Add custom VGLPaint type

26 Jan 2026, 17:19

None of this is trivial, as it would likely require modifying the shader combinatory.

We could expose a mechanism to use custom per-vertex colors, but that would also require allowing custom shaders for solid paints.

Please feel free to modify the source code and suggest changes in a ticket.

Who is online

Users browsing this forum: Google [Bot] and 2 guests