Difference in rendering properties vs Linux/OSX and Windows

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference in rendering properties vs Linux/OSX and Windows

odinsbane
When I setup a scene with a mesh, on windows it renders nicely using a material + a diffuse color. On linux and osx there isn't enough variation in the color. It switches pretty drastically, and leaves my objects with a mottled appearance.

screen shot with mottled mesh

The mesh is an indexed triangle array.

    IntexedTriangleArray surfaces = new IndexedTriangleArray(nodes.size(), GeometryArray.COORDINATES|GeometryArray.NORMALS, 3*triangles.size());
    //set the positions, indexes and normals here.
    Shape3D shape =  new Shape3D(surfaces);

The problem could lie in my normal calculation, but it works on windows.

I create the appearance with a material using the 5 parameters.

    private Appearance createSurfaceAppearance() {
        Appearance a = new Appearance();
        float[] rgb = color.getRGBComponents(new float[4]);

        Color3f ambient = new Color3f(adjust(rgb, amb));
        Color3f emmisive = new Color3f(adjust(rgb, emm));
        Color3f diffuse = new Color3f(adjust(rgb, dif));
        Color3f specular = new Color3f(adjust(rgb, spec));

        Material mat = new Material(
                ambient,
                emmisive,
                diffuse,
                specular,
                shininess);
        a.setMaterial(mat);
       
        return a;
    }

The adjust method takes a value between 0 and 2. If the value is less than 1 it decreases the magnitude of each component. If the value is > 1 then the value above 1 is added to the color. Eg. 0 is black, 1 is the desired color and 2 is white.

I render the scene with some lights.

        ambientLight = new AmbientLight(new Color3f(new float[]{
                ambient, ambient, ambient
        }));
        directionalLightA = new DirectionalLight(
            new Color3f(directional, directional, directional),
                dir);

`ambient` and `directional` are values between 0 and 1.

There are a lot of ways I could be doing this wrong, and I am willing to make a complete working example if that helps. It's just the difference is between windows and linux/osx so maybe there is a default parameter I need to change.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Difference in rendering properties vs Linux/OSX and Windows

gouessej
Administrator
Hello

Which hardware, which version of Java and which version of Java3D and JOGL do you use on your computer?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Difference in rendering properties vs Linux/OSX and Windows

odinsbane
The image shown above is using Java 25 on OSX 26.01 M series.

From `Map<?, ?> vuMap = VirtualUniverse.getProperties();`

j3d.pipeline, JOGL
j3d.specification.vendor,
j3d.specification.version, 1.7
j3d.version, 1.7.2_final

I'm using JOGL 2.6

If I query the properties of a canvas 3D.

    GraphicsConfiguration config = GraphicsEnvironment
                .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getBestConfiguration(template);
    Map<?, ?> c3dMap = new Canvas3D(config).queryProperties();

Then I get:

textureEnvCombineAvailable true
textureImageUnitsCombinedMax 16
textureAnisotropicFilterDegreeMax 16.0
texture3DHeightMax 2048
textureLodOffsetAvailable false
texture3DDepthMax 2048
textureLodRangeAvailable true
textureHeightMax 16384
textureFilter4Available false
doubleBufferAvailable true
compressedGeometry.majorVersionNumber 1
stereoAvailable true
textureAutoMipMapGenerationAvailable true
sceneAntialiasingAvailable true
compressedGeometry.minorVersionNumber 0
texture3DWidthMax 2048
compressedGeometry.minorMinorVersionNumber 2
vertexAttrsMax 10
shadingLanguageGLSL true
sceneAntialiasingNumPasses 1
native.vendor Apple
textureUnitStateMax 8
native.version 2.1 Metal - 90.5
textureImageUnitsMax 16
textureNonPowerOfTwoAvailable true
textureBoundaryWidthMax 1
native.renderer Apple M4 Pro
textureCoordSetsMax 8
texture3DAvailable true
textureImageUnitsVertexMax 16
textureWidthMax 16384
maxVaryingVectors 0
stencilSize 0
textureCombineDot3Available true
textureDetailAvailable false
textureCubeMapAvailable true
textureSharpenAvailable false
textureCombineSubtractAvailable true
textureColorTableSize 0

For a linux setup, it is running through a VNC with an NVIDIA. I can provide the same information if it helps.

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Difference in rendering properties vs Linux/OSX and Windows

gouessej
Administrator
Please can you try without VNC and without any virtual machine?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Difference in rendering properties vs Linux/OSX and Windows

odinsbane
Both linux and osx produce the same results. I get a sort of mottled appearance.

- locally running on osx 26.01 M series and linux (fedora 42 gnome + wayland + nvidia gpu)
- running remotely with vnc or x forwarding rocky linux 8

Java3D built in shapes/primitives render fine. So I changed the way I update my values.

From this:

        surfaces = new IndexedTriangleArray(nodes.size(), GeometryArray.COORDINATES|GeometryArray.NORMALS, 3*triangles.size());
        surfaces.setCoordinates(0,positions);
        surfaces.setCoordinateIndices(0,triangle_index);
        surfaces.setNormals(0, normals);
        sufaces.setNormalIndices(0, triangle_index);
        surface_object.setGeomtry(surfaces);

To this:

        surfaces = new IndexedTriangleArray(nodes.size(), GeometryArray.COORDINATES, 3*triangles.size());
        surfaces.setCoordinates(0,positions);
        surfaces.setCoordinateIndices(0,triangle_index);

        NormalGenerator ng = new NormalGenerator();
        GeometryInfo gi = new GeometryInfo(surfaces);
        ng.generateNormals(gi);
        surface_object.setGeometry( gi.getGeometry() );

Now everything seems to render normally. I don' know why this fixes it. The normals I was calculating worked fine on windows and older versions of java3d but the new way is better for multiple reasons.


As a side note, these examples https://github.com/philjord/java3d-examples do not work for me on osx. I had to manually specify all of the jogl/glugen/jocl et. libraries other wise it defaulted to the 2.5 versions which crash on arm based mac I'm using. Then the program doesn't crash, but it also doesn't initialize a java3d canvas properly. I can start an issue there though.

Reply | Threaded
Open this post in threaded view
|

Re: Difference in rendering properties vs Linux/OSX and Windows

gouessej
Administrator
Ensure that there is no other version conflicting on your machine under OS X. Maybe fill a bug report.
Julien Gouesse | Personal blog | Website