Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect rendering with Nvidia Quadro K4100M (driver number 332.21) under Windows 7 #29

Closed
jimbok8 opened this issue Feb 26, 2018 · 13 comments

Comments

Projects
None yet
2 participants
@jimbok8
Copy link

commented Feb 26, 2018

For give me for being naïve but I had assumed that this project was ready to use - I am getting rendering errors with JOGL
image

With the Renanse/Ardor3D version running with LWJGL I do not get errors:
image

I am curious - does this mean that Ardor3D will never work correctly with JOGL?
Or is it just a matter of time/resources?

PS Please do not take this as criticism - I am a great admirer of all your fantastic work and achievements in this area!

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

Hey

At first, the title of your issue is very inaccurate.

Secondly, the fact that you have one problem doesn't mean that the whole rendering with JOGL doesn't work at all. Keep in mind that several softwares in production (and some in pre-beta and alpha) are using JogAmp's Ardor3D Continuation.

Please can you take a few minutes to indicate which test case you use and/or to provide a sscce? Indicate which revision of JogAmp's Ardor3D Continuation you use too, the JRE, the graphics card, etc... I cannot fix a bug that I cannot reproduce. Have you modified the "Shapes example"? Does it work better when you revert some recent changes?

Moreover, as you use the legacy version of Ardor3D provided by Renanse, I advise you to reduce the number of variants by running it with JOGL so that we can find the culprit easier. I remember that I found a bug when using interlaced VBOs in Renanse's version several years ago but he didn't reproduce it and I didn't succeed in fixing it. If the bug was already in Renanse's version, we will probably work together to fix it so that both "forks" benefit of our efforts.

By the way, I don't take your report as a criticism but there is a huge contradiction between your last sentence and the rest of your post that lacks of balancing as you don't even consider that your own code could be to blame just because it works as is with the backend I removed (yes it's a JogAmp project) and you don't seem to realize that finding one bug doesn't mean that the whole product doesn't work. When I gather an apple, if there is only a small rotten part, I'll remove this part and eat the rest, I won't throw the whole apple into the bin.

This branch is 183 commits ahead, 7 commits behind Renanse:master. Where is the matter of time or resources?

@gouessej gouessej self-assigned this Feb 26, 2018

@gouessej gouessej added the bug label Feb 26, 2018

@gouessej gouessej added this to the 1.0.0 milestone Feb 26, 2018

@jimbok8

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

Thanks for the quick response.

I have now noticed that the error only occurs with 24 bpp.
With 16 bpp the scene renders correctly.

Here is the SSCCE "SimpleShapesExample.java" (derived from ShapesExample to limit the shapes and remove BMTextBackground), attached as a zip file.

SimpleShapesExample.zip

I am using:
java.vendor="Sun Microsystems Inc."
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode).

with this:
INFO: Display Vendor: NVIDIA Corporation
INFO: Display Renderer: Quadro K4100M/PCIe/SSE2
INFO: Display Version: 4.4.0
INFO: Shading Language Version: 4.40 NVIDIA via Cg compiler

Windows 7 Professional
Intel Core i7-4700MQ with 32 GB RAM

@jimbok8 jimbok8 closed this Feb 26, 2018

@jimbok8

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

Sorry - not sure why the closed option was activated.
Also, not sure if the file was uploaded correctly, so I have included it as text below:

package ardor3d.physics.demo;

/**
 * Copyright (c) 2008-2012 Ardor Labs, Inc.
 *
 * This file is part of Ardor3D.
 *
 * Ardor3D is free software: you can redistribute it and/or modify it
 * under the terms of its license which may be found in the accompanying
 * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
 */

//package com.ardor3d.example.basic;

import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
import com.ardor3d.framework.Canvas;
import com.ardor3d.image.Texture;
import com.ardor3d.image.TextureStoreFormat;
import com.ardor3d.input.logical.InputTrigger;
import com.ardor3d.input.logical.MouseMovedCondition;
import com.ardor3d.input.logical.TriggerAction;
import com.ardor3d.input.logical.TwoInputStates;
import com.ardor3d.intersection.BoundingPickResults;
import com.ardor3d.intersection.PickData;
import com.ardor3d.intersection.PickResults;
import com.ardor3d.intersection.PickingUtil;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Ray3;
import com.ardor3d.math.Vector2;
import com.ardor3d.renderer.state.BlendState;
import com.ardor3d.renderer.state.MaterialState;
import com.ardor3d.renderer.state.RenderState.StateType;
import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Node;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.controller.SpatialController;
import com.ardor3d.scenegraph.hint.CullHint;
import com.ardor3d.scenegraph.shape.Sphere;
import com.ardor3d.scenegraph.shape.Teapot;
import com.ardor3d.scenegraph.shape.Torus;
import com.ardor3d.ui.text.BasicText;
import com.ardor3d.util.TextureManager;

/**
 * A display of intrinsic shapes (e.g. Box, Cone, Torus).
 */
@Purpose(htmlDescriptionKey = "com.ardor3d.example.basic.ShapesExample", //
thumbnailPath = "com/ardor3d/example/media/thumbnails/basic_ShapesExample.jpg", //
maxHeapMemory = 64)
public class SimpleShapesExample extends ExampleBase {
    private int wrapCount;
    private int index;
    private BasicText _text;
    private Node _textNode;
    private PickResults _pickResults;
    private Spatial _picked = null;
    private SpatialController<Spatial> _pickedControl;

    public static void main(final String[] args) {
        start(SimpleShapesExample.class);
    }

    @Override
    protected void initExample() {
        _canvas.setTitle("Shapes Example");

        addMesh(new Sphere("Sphere", 32, 32, 3));
        addMesh(new Teapot("Teapot"));
        addMesh(new Torus("Torus", 32, 16, 1.0, 2.5));

        final TextureState ts = new TextureState();
        ts.setTexture(TextureManager.load("media/images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear,
                TextureStoreFormat.GuessCompressedFormat, true));
        _root.setRenderState(ts);

        final BlendState bs = new BlendState();
        bs.setBlendEnabled(true);
        _root.setRenderState(bs);

        // Set up a reusable pick results
        _pickResults = new BoundingPickResults();
        _pickResults.setCheckDistance(true);

        setupText();

        // Set up picked pulse
        _pickedControl = new SpatialController<Spatial>() {
            ColorRGBA curr = new ColorRGBA();
            float val = 0;
            boolean add = true;

            @Override
            public void update(final double time, final Spatial caller) {
            }
        };
    }

    private void setupText() {
        // Set up our pick label
        _textNode = new Node("textNode");
        _textNode.setTranslation(20, 20, 0);
        _textNode.getSceneHints().setCullHint(CullHint.Always);
        _root.attachChild(_textNode);

        _text = BasicText.createDefaultTextLabel("JIM", "pick");
        _text.getSceneHints().setOrthoOrder(0);
        _textNode.attachChild(_text);

        final Texture border = TextureManager.load("media/images/glass.jpg", Texture.MinificationFilter.Trilinear, true);

//        final BMTextBackground outerBorder = new BMTextBackground("bg1", _text, border);
//        outerBorder.setTexBorderOffsets(0.2f);
//        outerBorder.setContentPadding(10);
//        outerBorder.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
//        outerBorder.getSceneHints().setOrthoOrder(2);
//        outerBorder.setBackgroundColor(ColorRGBA.LIGHT_GRAY);
//        _textNode.attachChild(outerBorder);

//        final BMTextBackground innerBG = new BMTextBackground("bg2", _text, border);
//        innerBG.setTexBorderOffsets(0.2f);
//        innerBG.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
//        innerBG.getSceneHints().setOrthoOrder(1);
//        innerBG.setBackgroundColor(ColorRGBA.BLUE);
//        _textNode.attachChild(innerBG);
    }

    @Override
    protected void registerInputTriggers() {
        super.registerInputTriggers();

        // Add mouse-over to show labels

        _logicalLayer.registerTrigger(new InputTrigger(new MouseMovedCondition(), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                // Put together a pick ray
                final Vector2 pos = Vector2.fetchTempInstance().set(inputStates.getCurrent().getMouseState().getX(),
                        inputStates.getCurrent().getMouseState().getY());
                final Ray3 pickRay = Ray3.fetchTempInstance();
                _canvas.getCanvasRenderer().getCamera().getPickRay(pos, false, pickRay);
                Vector2.releaseTempInstance(pos);

                // Do the pick
                _pickResults.clear();
                PickingUtil.findPick(_root, pickRay, _pickResults);
                Ray3.releaseTempInstance(pickRay);

                if (_pickResults.getNumber() > 0) {
                    // picked something, show label.
                    _textNode.getSceneHints().setCullHint(CullHint.Never);

                    // set our text to the name of the ancestor of this object that is right under the _root node.
                    final PickData pick = _pickResults.getPickData(0);
                    if (pick.getTarget() instanceof Spatial) {
                        final Spatial topLevel = getTopLevel((Spatial) pick.getTarget());
                        if (!topLevel.equals(_picked)) {
                            clearPicked();
                            _picked = topLevel;
                            _picked.addController(_pickedControl);
                        }
                        _text.setText(topLevel.getName());
                    }
                } else {
                    // No pick, clear label.
                    _textNode.getSceneHints().setCullHint(CullHint.Always);
                    _text.setText("");

                    clearPicked();
                }
            }

            private void clearPicked() {
                if (_picked != null) {
                    final MaterialState ms = (MaterialState) _picked.getLocalRenderState(StateType.Material);
                    //ms.setAmbient(ColorRGBA.DARK_GRAY);
                    ms.setAmbient(ColorRGBA.WHITE);
                    _picked.removeController(_pickedControl);
                }
                _picked = null;
            }

            private Spatial getTopLevel(final Spatial target) {
                if (target.getParent() == null || target.getParent().equals(_root)) {
                    return target;
                } else {
                    return getTopLevel(target.getParent());
                }
            }
        }));

    }

    private void addMesh(final Spatial spatial) {
        spatial.setTranslation((index-1) * 7 , 0, -10);
        if (spatial instanceof Mesh) {
            ((Mesh) spatial).updateModelBound();
        }
        final MaterialState ms = new MaterialState();
        //ms.setAmbient(ColorRGBA.DARK_GRAY);
        ms.setAmbient(ColorRGBA.WHITE);
        
        spatial.setRenderState(ms);
        _root.attachChild(spatial);
        index++;
    }
}

@jimbok8 jimbok8 reopened this Feb 26, 2018

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

Thank you, you suggested a workaround. Actually, I assume that this bug is reproducible with Renanse's version. Please can you use 24 bpp with JOGL and his version to confirm?

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

I'll try to reproduce your bug on another similar graphics card. I suspect a driver bug and maybe the other backend you use selects 16 bpp by default.

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

Please can you indicate the version number of your driver and can you confirm you use the basic profile in the Nvidia control pannel? Does your computer support Optimus? If it uses Optimus, it can switch from a GPU to another at runtime.

@jimbok8

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

With the Renanse/Ardor3D version from Github:
Correct rendering with LWJGL 2.9.3 with 16 bpp
Correct rendering with LWJGL 2.9.3 with 24 bpp
Correct rendering with JOGL 2.0rc11 with 16 bpp
Incorrect rendering with JOGL 2.0rc11 with 24 bpp

nVidia driver version is 332.21
DirectX runtime version is 11.0

Yes the nVidia control panel indicates that the base profile is selected.

I have no idea what Optimus is, I think that the answer will be no.

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

Thank you for the feedback. Your bug isn't reproducible under Microsoft Windows 10 with the graphics card Nvidia Quadro 600:

INFOS: Display Vendor: NVIDIA Corporation
INFOS: Display Renderer: Quadro 600/PCIe/SSE2
INFOS: Display Version: 4.5.0 NVIDIA 353.30
INFOS: Shading Language Version: 4.50 NVIDIA

Numerous laptops with Nvidia graphics chips use Optimus, you should see it in your control panel:
Screen capture

Is NVIDIA Optimus mentioned in your case?

The problem is that Optimus might pick another GPU at runtime or when starting the example. We have no control on that.

Moreover, if Optimus isn't involved, you should simply update your driver as it seems to be very old. The graphics card I used for the test was manufactured in 2010, it's older than yours but my driver is a lot less old and the current behaviour is probably caused by a driver bug. I'll retry your example. JOGL is mostly a Java binding for the OpenGL API, we don't do anything special when you select "24 bpp" instead of "16 bpp" and I have no idea of what the other binding does under the hood.

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

Ok I've just tested both ShapesExample and SimpleShapesExample with JogAmp's Ardor3D Continuation 1.0-Snapshot + JOGL 2.3.2, both with "16 bpp" and "24 bpp" again. I still don't reproduce your bug.

If you modify the near plane of the frustum to move it too close from the shapes, you'll obtain a similar effect even in a program written in plain C.

In my humble opinion, there is something wrong in the OpenGL driver in the depth buffer only when asking for "24 bpp". It's neither a JOGL bug nor a bug of JogAmp's Ardor3D Continuation. Either the other binding silently ignores your query and uses "16 bpp" whatever you pass, or Renanse's Ardor3D doesn't pass this information (it's probably not the case). I'll check whether a more recent driver is available for your hardware.

@jimbok8

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

OK, thanks very much for work on this and your quick response.
I will put in a request for IT to update the driver (it is a corporate PC and we have outsourced the IT support, so this will be painful).

@jimbok8 jimbok8 closed this Feb 26, 2018

@gouessej

This comment has been minimized.

Copy link
Owner

commented Feb 26, 2018

Please use the driver 368.39, it should work under Windows 7 64-bit. I haven't read the whole release note. Let me know whether it fixes your bug.

@gouessej gouessej changed the title Incorrect rendering with JOGL Incorrect rendering with Nvidia Quadro K4100M (driver number 332.21) under Windows 7 Feb 26, 2018

@jimbok8

This comment has been minimized.

Copy link
Author

commented Mar 12, 2018

As recommended I have now updated my nVidia driver - to version 377.11.
I can now report rendering is as expected with JOGL 2.0rc11 with both 24 bpp and 16bpp.
Thank you for your help.
Jim

@jimbok8 jimbok8 reopened this Mar 12, 2018

@jimbok8 jimbok8 closed this Mar 12, 2018

@gouessej

This comment has been minimized.

Copy link
Owner

commented Mar 14, 2018

Thank you very much for the feedback.

However, please keep in mind that JOGL 2.0rc11 is terribly obsolete, please use the very latest version of JogAmp's Ardor3D Continuation with JOGL 2.3.2. If you don't use the latest version, any bug that you will report later will be simply rejected and you'll be bothered by the bugs we've already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.