mkeeter / kokopelli

Script-based CAD/CAM in Python (deprecated)
https://mattkeeter.com/projects/kokopelli
Other
298 stars 49 forks source link

How to improve rendering #4

Closed rahji closed 10 years ago

rahji commented 10 years ago

Hi, is there anything I can do to make the rendering look better? Using the shaded or normals shading modes always looks like it's missing parts of the model. The rendering changes with any modifications to the code (including removing a blank line, for example), but it never seems to be without problems. Is there something I'm missing or is it just meant to be a rough approximation of the model? The attached image is a rendering of this code:

from koko.lib.shapes import *
c = cube(0,1,0,1,0,1)
cad.shape = c

image

rahji commented 10 years ago

The bearings example:

image

PartyTonight commented 10 years ago

I can't reproduce your problem. I can see the cube and the bearing just fine. Are you on a Mac or Ubuntu? Maybe the openGL drivers you are using have something to do.

mkeeter commented 10 years ago

Yes, that looks like a graphics driver issue, although I've also seen similar glitches when running in a virtual machine. Can you install binary drivers for your graphics card and see if that makes a difference?

rahji commented 10 years ago

I'm using Ubuntu 13.04 Raring Ringtail.

Linux stinkpad 3.8.0-30-lowlatency #22-Ubuntu SMP PREEMPT Mon Aug 26 22:31:40 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

It's a Thinkpad T410 with Intel HD Graphics 4000 (no NVidia card). I don't have any other graphics related troubles (with blender, processing w/P3D, openscad, etc). I just tried installing the Intel drivers anyway, to see if it would make a difference. I'm not sure if they were installed properly since the website says that it doesn't support the lowlatency kernel. https://01.org/linuxgraphics/downloads/2013/intelr-linux-graphics-installer-version-1.0.2 In any case, things look the same in kokopelli

mkeeter commented 10 years ago

Okay, try out the latest commit (3cfbce591ba4d81ba9f4559994477d6dd031c1f0).

wx.glcanvas has fairly sketchy documentation, but these changes fixed glitchy rendering on my Ubuntu VM.

rahji commented 10 years ago

I did this:

# git update
# git reset --hard origin/master
# make
# sudo make install

When I try to run kokopelli from /usr/local/bin now, I get:

[||||||||||]    starting...                                                     
Traceback (most recent call last):
  File "/usr/local/bin/kokopelli", line 71, in <module>
    app = App()
  File "/usr/local/lib/python2.7/dist-packages/wx/_core.py", line 8631, in __init__
    self._BootstrapApp()
  File "/usr/local/lib/python2.7/dist-packages/wx/_core.py", line 8196, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "/usr/local/bin/koko/app.py", line 74, in OnInit
    koko.FRAME = MainFrame(self)
  File "/usr/local/bin/koko/frame.py", line 83, in __init__
    koko.GLCANVAS = GLCanvas(self, size=(300, 300))
  File "/usr/local/bin/koko/glcanvas.py", line 53, in __init__
    self.context = glcanvas.GLContext(self)
  File "/usr/local/lib/python2.7/dist-packages/wx/glcanvas.py", line 67, in __init__
    _glcanvas.GLContext_swiginit(self,_glcanvas.new_GLContext(*args, **kwargs))
wx._core.PyAssertionError: C++ assertion "fbc" failed at /home/rduarte/git/kokopelli/util/wxPython-src-2.9.4.0/src/unix/glx11.cpp(51) in wxGLContext(): invalid GLXFBConfig for OpenGL

I don't know a whole lot about python or wxpython so let me know if I did something wrong. Thanks

mkeeter commented 10 years ago

It looks like your card doesn't support a 32-bit depth buffer. I've added a really silly fix (823a93438d9c5f75e16d19339a9ab96e5d971b0c) that might get it working: we now attempt to construct the OpenGL canvas with a bunch of different depth buffer sizes, stopping when we get one that doesn't trigger an assertion failure.

It's crude, but the correct way to do it (using GLCanvas.IsDisplaySupported) crashes on my Linux VM.

These are messy and uncharted backwaters of wx -- thanks for your help debugging.

rahji commented 10 years ago

Yay! Works great on my end. Thanks for the help!