Put wireframe whiout hidding the whole material

Hello, am working on a turn base game and i want to put something around my cells so they can be more visible. Right now they are make of a white tranlusid material but they are simply not visible enouf. I was thinking i could put the wireFrame on the material but then they lose the calm and sweet material they had, plus it put a line in the middle of the box.

I was thinking i could put a Grid over my whole map but then again, as some cells are lower/higher then order i can’t just put it all over the place.

My idear right now is too add a single grid over every cell i have, but this is a lot more for the computer, and adding 2 geom indeed of one seem to me like to much. So am seeking a better solution, if anyone have one.

Thanks :smiley:

As far as I’m aware, the only way to do this would be to duplicate your geometry/spatial and have both materials applied, one regular and one wireframe, each to their own geometry.

There may be an issue with Z-Fighting, so you may want to upscale the geometry that has the wireframe material by a fractional amount.

It’s also possible that someone has/can make a shader which does this all. I haven’t seen one myself personally, so the above is the best option as far as I’m concerned.

Be warned if you do duplicate the geometry, any animations or adjustments you make should be done on both objects. Also, I would avoid going overboard with the duplicated objects, as it will drop your FPS with each new object.

I don’t know much about tampering with the render cycle, but maybe there’s a way to modify the render of that object to render twice with each material instead.

1 Like

O well, thanks for the anwser but i actully had to use the tecnique i call befaure : creating a second geom at the same form and size of the cube i had and put it over.

Problem is, i had some wierd stuff doing that.

Grid grid = new Grid(2,2,size * 2) ;
    Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
      mat.setColor("Color", ColorRGBA.Black);

For some reason i had to double my size and use a 2 per 2 line indead of 1 per 1 cause it was showing nothing… and i also had to double the size… but it work now.

Anyway, i think the grid actully look better then just the wireframe it self, but i still was hoping i could just use one geom to boost the effectiveness… Look like i can’t whit this method of yours, so i might as well kept things this way xD

Still, thanks you again x)

I’m sure there’s a way to do it with just the one geometry. I believe a scene processor could do it. I haven’t dabbled into the whole thing my self, so I could be confused with something else.

Edit: I’ve done it. I don’t know if the way I’ve done it is elegant or not, but it seems to work.

You need to create a new post viewport via:

secondPass = renderManager.createPostView("SecondPass", cam);

You also need to attach your scene to it:


Add this to your “simpleRender” or other method if you are using AppStates:


Your wireframe material should disable depth testing, and of course, have the wireframe flag set to true.

At my work (uses legacy OpenGL) you would make wireframes look better by using glEdgeFlagPointer() which holds a bunch of flags for each vertex to say if it is at a boundary edge or not. There should be a modern shader alternative to that somewhere on the web.