Highlight Vertex

Hey, I render a model with the wireframe amterial, but I need to highlight some triangles (i have the indexes of them). I suspect have to create a own shader for that, but I have no idea where to start ?

To start trying around with shaders its probably easiest to install “Editor Shader Support” in jMP and copy & pasting a similar shader and j3md file from the jmonkeyengine3.jar in the library node of the project to your assets folder. Then you can start editing the shader and j3md file and by creating a j3m file with the j3m editor you can preview the results or try the material on models in the jMP SceneEditor.

“Editor Shader Support” will give you code highlighting and a bit of error checking on the shader syntax which should help a bit when starting coding shaders.

Theres also an excellent wiki page by nehon on the topic of shaders in jme3.



You actually don’t need a shader. If you have the indices, you can get the vertex positions for them and construct a mesh containing just that one triangle. Then the rest should be easy.

Well i read a bit more into the opengl.org wiki and now I have some questions I’m not quite sure with:

1.) I could just create a new Mesh with the data from the Traingles as suggested

Pro: low memory requirement only needed data

Contra: If I need to change the highlighted Traingle often I have to rebuild it every time, workst case once per frame

2.) I could use the original Vertex data + Original index buffer, but use a half transparent texture, and change the texture coordinates so that ony the traingels I want to have are visible.

3.) I could do kinda the same in the FragmentShader as far as i understood it?!

4.) I could use a Geometry Shader, and modify the mesh on the fly so only the sides i want remain?

5.) I could use the vertex buffer but change the Index buffer in a way so taht only the wanted Vertexes are renderd?

Can you tell me if I understood everything correctly or if there are any misunderstandings? Also wich technique would you prefer?

Ps: Do we have Transform feedbacks? As I saw a demo with that running fluently with several thousand particles


(for the ones not capable of runnig it some eyecandy with a similar approach)

Considering that even the worst video card can handle 6 GB/s bandwidth, I don’t think it would be an issue to update a few triangles per frame.

One question I still wonder about, as far as I understood, for a Triangle is there any sense to define the index buffer? as I do not reuse any of the vertexes anyway?

If I remember correctly, you don’t need to have an index buffer to draw a mesh. So yeah it should work.

Well I did it now that way, and it kinda works if the main model is in wireframe.

However how can i ensure that my trianglemesh is always renderd above the main one? Because I have some problems since both the gightlighted and the original one are at exactly the same position.

You can disable Z test: