Bad Rendering Result with the Jogl-Viewer

Have jReality programming problems or questions? Post them here.
Post Reply
capri333
Posts: 9
Joined: Thu 19. Apr 2012, 15:49

Bad Rendering Result with the Jogl-Viewer

Post by capri333 » Thu 21. Jun 2012, 15:50

Hello,

i want to use the JOGL-Viewer for better performance (<- it will be faster).
The problem is with SOFTViewer i get the following:
Image

and with the JOGL-Viewer i see this:
Image

I don't want to have the black regions.
What must i change to get with the JOGL-Viewer the same result as with the SOFTViewer?

Can anyone help, please
Anke

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Bad Rendering Result with the Jogl-Viewer

Post by Andre » Thu 21. Jun 2012, 16:31

Hi Anke,

do you have this problems for other surfaces aswell or is it just for your car-example? Can you pls try another geometry aswell. If you get the same error it would be nice if you could post some parts of your code, so that we can easier rebuild your problem.

best
Andre

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: Bad Rendering Result with the Jogl-Viewer

Post by steffen » Thu 21. Jun 2012, 16:53

if possible just post the geometry data or email it.

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Bad Rendering Result with the Jogl-Viewer

Post by Andre » Thu 21. Jun 2012, 16:56

steffen wrote:if possible just post the geometry data or email it.
thats the other way around ;)

capri333
Posts: 9
Joined: Thu 19. Apr 2012, 15:49

Re: Bad Rendering Result with the Jogl-Viewer

Post by capri333 » Fri 22. Jun 2012, 10:06

Hello Andre, hello Steffen,

that happens by all the images i want to show.

What i load are JT-files. For that i use another project called JT-Viewer (which used JReality).
After calling the methods from JT-Viewer to load the file, i get a SceneGraphComponent, that's geometry is null.

I've tried following:
- Get the appearance of the sceneGraphComponent and set different combinations of attributes.
- Make a new appearance with different combinations of attributes and set it to the SceneGraphComponent.
- Make a DefaultGeometryShader with ShaderUtility.createDefaultGeometryShader(app, true).
DefaultGeometryShader dgs = (DefaultGeometryShader) ShaderUtility.createDefaultGeometryShader(app, true);
dgs.setShowLines(false);
dgs.setShowPoints(false);
DefaultPolygonShader dps = (DefaultPolygonShader) dgs.getPolygonShader();
dps.setDiffuseColor(Color.BLUE);
dps.setSpecularColor(Color.BLUE);
dps.setAmbientColor(Color.BLUE);
dps.setSmoothShading(false); // or true
- Make a RenderingHintsShader with RenderingHintsShader rhs = (RenderingHintsShader) ShaderUtility.createDefaultRenderingHintsShader(ap, true)
and change values.

...the image still have the black regions.

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Bad Rendering Result with the Jogl-Viewer

Post by Andre » Fri 22. Jun 2012, 13:07

Anyway, can you pls upload some of your geometries? So we can test them aswell.

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: Bad Rendering Result with the Jogl-Viewer

Post by steffen » Fri 22. Jun 2012, 13:30

The easiest way would be to save the "content" node from the jreality viewer, as a jrs file. And, let us know about your hard- and software configuration, graphics card, os, graphics card driver.

capri333
Posts: 9
Joined: Thu 19. Apr 2012, 15:49

Re: Bad Rendering Result with the Jogl-Viewer

Post by capri333 » Fri 22. Jun 2012, 16:42

First, thanks for your very fast responses.

i have tried to export the scene as .jrs, but this jrs-file has 0 Bytes !!!

When i want to get the geometry from the sceneGraphComponent, that i get from the JT_Viewer methods
and that i set as content, this geometry is null.

I wonder all the time, how and what will be rendered.

... and the problem with the black regions happens only with the JOGL-Viewer (not the SoftViewer) with Linux and Windows 7
on 4 different PC's with different hard- and software configurations.

Can any other export(RIB, SVG,PS, ...) help to understand, what's the problem?

Say goodby till monday,
Anke

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Bad Rendering Result with the Jogl-Viewer

Post by gunn » Sun 24. Jun 2012, 14:41

This behavior in the JOGL backend is not correct; even if the normals of some faces are flipped with respect to others, the default behavior is to shade all faces, back- and front-facing, the same. So it will be good to get a copy of this data and see why this is not being rendered as it should.

In the meantime, it should be possible to get the normals in better shape. Here's how:

Presumably the geometry is contained in a child of the SceneGraphCompnent you're getting from JT_Viewer. To get this geometry, use de.jreality.util.SceneGraphUtility.getFirstGeometry(), and cast it to an IndexedFaceSet ifs.

Then, try adjusting the the normals by calling the methods de.jreality.geometry.IndexedFaceSetUtility.makeConsistentOrientation(ifs) followed by de.jreality.geometry.IndexedFaceSetUtility.calculateAndSetNormals(ifs).
Here's the code:

Code: Select all

import de.jreality.geometry.IndexedFaceSetUtility;
import de.jreality.util.SceneGraphUtility;
IndexedFaceSet ifs =  (IndexedFaceSet) getFirstGeometry(sgc);
boolean b = makeConsistentOrientation(ifs);
if (!b) System.err.println("Cannot orient");
calculateAndSetNormals(ifs);
If the geometry is spread out over several instances of IndexedFaceSet, the above method will only get the first one. In that case, try using an instance of the class de.jreality.geometry.GeometryMergeFactory and call the method mergeIndexedFaceSets(SceneGraphComponent sgc) -- this should return a single IFS representing all IFS's contained in the scene graph rooted at sgc.
jReality core developer

capri333
Posts: 9
Joined: Thu 19. Apr 2012, 15:49

Re: Bad Rendering Result with the Jogl-Viewer

Post by capri333 » Tue 26. Jun 2012, 12:01

Hello gunn,

I have done, what you have described,
but there still the black regions.

Meanwhile i have seperate the viewer as a little standalone project with the car.jt.
When you can give me your mail adress, i will send you this project.

Maybe you have an idea what's going wrong.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Bad Rendering Result with the Jogl-Viewer

Post by gunn » Wed 27. Jun 2012, 20:24

You can send it to gunn [@] math.tu-berlin.de.
jReality core developer

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Bad Rendering Result with the Jogl-Viewer

Post by Andre » Thu 28. Jun 2012, 10:36

Hey Charles,

I've edited you post to prevent you from spam...

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Bad Rendering Result with the Jogl-Viewer

Post by gunn » Thu 28. Jun 2012, 17:12

Try replacing the class ViewerContentLoader with the following code. The results are quite surprising. The car's parts are properly colored, there are no more random black polygons. The question remains, why the geometry has to be merged into a single geometry (with over 300,000 polygons!) in order for the rendered picture to be correct (in either soft or jogl viewer). We are looking into this. Pictures below.

Code: Select all

package main.java.velian.jogl_viewer_problem.util;

import java.io.IOException;
import java.nio.BufferUnderflowException;
import java.util.logging.Logger;

import de.jreality.geometry.GeometryMergeFactory;
import de.jreality.geometry.IndexedFaceSetUtility;
import de.jreality.plugin.basic.Content;
import de.jreality.plugin.content.ContentLoader;
import de.jreality.reader.Readers;
import de.jreality.scene.IndexedFaceSet;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.util.Input;
import de.jreality.util.SceneGraphUtility;

public class ViewerContentLoader extends ContentLoader {

	public final static Logger logger = Logger
			.getLogger(ViewerContentLoader.class.getName());

	public SceneGraphComponent loadFile(String file, Content content)
			throws IOException {
		SceneGraphComponent read = null;
		if (file != null && !file.isEmpty() && !file.equals("NULL")) {
			Input input = Input.getInput(file);
			try {
				read = Readers.read(input);
			} catch (BufferUnderflowException ex) {
//				logger.debug("could not load the image");
			}
			GeometryMergeFactory gmf = new GeometryMergeFactory();
			IndexedFaceSet ifs = gmf.mergeIndexedFaceSets(read);
			input = null;
			file = null;

			SceneGraphUtility.removeChildren(read);
			read.setGeometry(ifs);
			
			try {
				boolean b = IndexedFaceSetUtility
						.makeConsistentOrientation(ifs);
				if (!b)
					System.err.println("Cannot orient");
				IndexedFaceSetUtility.calculateAndSetNormals(ifs);
			} catch (Exception ex) {
				ex.printStackTrace();
			}

			content.setContent(read);
		}
		return read;
	}

}
Attachments
car-02.jpg
car-02.jpg (71.85 KiB) Viewed 2820 times
car-01.png
car-01.png (225.42 KiB) Viewed 2820 times
jReality core developer

Post Reply