Hello,
have some problems rendering lines.
How can I make use of the polygon offset (that comes with OpenGL) in jME?
Did not find it, making a quick search…
Ogli
Have a look at how the pass system uses it.
hm,
I looked at OutlinePass but could not exactly find what I was looking for.
In the meantime I just gave the lines a litte offset in object space - but this is not a perfect solution to my problem.
What I want to do, is, render a line on a transparent surface - but the line should be a litte closer to the eye.
I want to do this without shaders - the only way in OpenGL would be polygon offset, I think.
ok, thanks anyway…
That's because Outline pass doesn't use it ShadowRenderPass does.
There's a method setPolygonOffset in Renderer you can call directly. But the Pass system (look at Pass.java) helps you do exactly what you want I think (a z offset).
ah, big thanks to the Llama…
Hi,
i have the exact same problem.
I have custom mesh to create a square planet surface with a grid and different heights (triangles with vertex color).
On top of that i want to put a white grid to make the fields visible.
I already implemented this before with JOGL and i used this code to achieve the desired effect:
... draw surface ...
gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); // Raster vor der Oberfläche malen ...
gl.glPolygonOffset(1.0f, 1.0f);
... draw grid ...
What you were saying sound like you solved it.
But i could not find the exact way how to do it.
Also i am using JME3 now.
Could you please post a few lines sample code of how exactly to do it?
Greetings Fino
material.getAdditionalRenderState().getPolyXXX
Thanks for the fast answer, but this did NOT work - no effect … i tried:
mat.getAdditionalRenderState().setPolyOffset(1, 1);
mat.getAdditionalRenderState().setPolyOffset(-1, -1);
mat.getAdditionalRenderState().setPolyOffset(10, 10);
Complete code:
Geometry grid = new Geometry(“PlanetGrid”, mesh);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f));
mat.getAdditionalRenderState().setPolyOffset(-1, -1);
grid.setMaterial(mat);
Maybe of relevance: The Surfcase has this:
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
Any clue why?
Oh … do i have to activate the Polygon Offset Mode like in my earlier JOGL sample code?
setPolyOffset has always worked for me. How is it that you’ve determined it isn’t working? What geometry is planet grid on top of that you are trying to get it to render in front of?
I solved it. I had put the setPolygonOffset on the wrong material.
This is how it WORKS:
The PlanetSurface:
Geometry grid = new Geometry(“PlanetSurface”, mesh);
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
mat.setFloat(“Shininess”, 25f);
mat.setBoolean(“VertexLighting”, true);
mat.setBoolean(“UseVertexColor”, true);
mat.setColor(“Diffuse”, ColorRGBA.White);
mat.getAdditionalRenderState().setPolyOffset(1, 1);
grid.setMaterial(mat);
The PlanetGrid (on top):
Geometry grid = new Geometry(“PlanetGrid”, mesh);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f));
grid.setMaterial(mat);
If i put the SetPolyOffest on the PlanetGrid, it won’t work at all (no matter if i put +1 or -1).
THANKS A LOT!