SFML community forums
Help => Graphics => Topic started by: brfsmn on May 16, 2020, 04:05:28 pm
-
I have a mesh or a drawing with multiple connected triangles and every node or vertex of these triangles in the mesh has a certain value (stress, strain etc.) and I want to draw a heat map for these values over my mesh.
In SFML tutorial, it was demonstrated that you could assign a color to every vertex in triangle native type, then color of triangle would be interpolated over color of the 3 nodes.
Is there's a way to get color interpolation to use specified 'neighboring nodes' and not just nodes in its own set of shape?
-
For anything beyond the simple color gradient between vertices, you may want to pick a shader, that will allow you to do a lot more.
-
You could manually interpolate the colours between the ones you wish to interpolate for each of the vertices between those two. Looks like it might be a simple task. Depends on what you mean specifically and if I've fully understood what you meant.
-
You could manually interpolate the colours between the ones you wish to interpolate for each of the vertices between those two. Looks like it might be a simple task. Depends on what you mean specifically and if I've fully understood what you meant.
This is an example of what I am trying to accomplish.
https://i.imgur.com/KUfK76H.png
The difference here is that he is using rectangular elements and I am using triangles but that's irrelevant.
On second thought, I think color interpolation for every triangle on its own might do job but if it didn't and I want to implement it myself, I would have to use shaders as eXpl0it3r suggested?
-
There is more detail required than just those rectangles. Each rectangle has more than just a simple interpolation of colours.
It's likely a good idea to subdivide that grid many times and the quads used would be a lot smaller. The grid would just be overlaid if required.
Another option would be to use texture(s) for each quad. The texture can be created "live" by using a render texture. For example, drawing the shapes onto the render texture and then using that texture for the quads.
That said, if you want the graphics card to do the processing for you, you can use a shader, but the shader will need to have all of the information with which to make the map.
And yes, of course, triangles are no different. In fact, quads (when distorted like in the image) don't interpolate colours as reliably as triangles. ;D