Giter VIP home page Giter VIP logo

panda3d / panda3d Goto Github PK

View Code? Open in Web Editor NEW
4.3K 201.0 770.0 157.65 MB

Powerful, mature open-source cross-platform game engine for Python and C++, developed by Disney and CMU

Home Page: https://www.panda3d.org/

License: Other

C++ 58.82% C 16.15% Python 12.93% Emacs Lisp 0.52% NSIS 0.13% Shell 0.01% Objective-C++ 0.90% Objective-C 0.07% HTML 0.02% Nemerle 0.01% Java 0.02% Batchfile 0.01% MAXScript 0.01% Roff 0.01% GLSL 0.01% CMake 0.96% SWIG 9.18% Assembly 0.21% Raku 0.04% Perl 0.01%
game-engine open-source panda3d cross-platform python panda3d-game-engine game-development opengl multi-platform gamedev

panda3d's Introduction

Build Status OpenCollective OpenCollective

Panda3D

Panda3D is a game engine, a framework for 3D rendering and game development for Python and C++ programs. Panda3D is open-source and free for any purpose, including commercial ventures, thanks to its liberal license. To learn more about Panda3D's capabilities, visit the gallery and the feature list. To learn how to use Panda3D, check the documentation resources. If you get stuck, ask for help from our active community.

Panda3D is licensed under the Modified BSD License. See the LICENSE file for more details.

Installing Panda3D

The latest Panda3D SDK can be downloaded from this page. If you are familiar with installing Python packages, you can use the following command:

pip install panda3d

The easiest way to install the latest development build of Panda3D into an existing Python installation is using the following command:

pip install --pre --extra-index-url https://archive.panda3d.org/ panda3d

If this command fails, please make sure your version of pip is up-to-date.

If you prefer to install the full SDK with all tools, the latest development builds can be obtained from this page.

These are automatically kept up-to-date with the latest GitHub version of Panda.

Building Panda3D

Windows

You can build Panda3D with the Microsoft Visual C++ 2015, 2017, 2019 or 2022 compiler, which can be downloaded for free from the Visual Studio site. You will also need to install the Windows SDK, and if you intend to target Windows Vista, you will also need the Windows 8.1 SDK.

You will also need the thirdparty dependency libraries available for the build scripts to use. These are available from one of these two URLs, depending on whether you are on a 32-bit or 64-bit system, or you can click here for instructions on building them from source.

After acquiring these dependencies, you can build Panda3D from the command prompt using the following command. Change the --msvc-version option based on your version of Visual C++; 2022 is 14.3, 2019 is 14.2, 2017 is 14.1, and 2015 is 14. Remove the --windows-sdk=10 option if you need to support Windows Vista, which requires the Windows 8.1 SDK.

makepanda\makepanda.bat --everything --installer --msvc-version=14.3 --windows-sdk=10 --no-eigen --threads=2

When the build succeeds, it will produce an .exe file that you can use to install Panda3D on your system.

Note: you may choose to remove --no-eigen and build with Eigen support in order to improve runtime performance. However, this will cause the build to take hours to complete, as Eigen is a heavily template-based library, and the MSVC compiler does not perform well under those circumstances.

Linux

Building Panda3D on Linux is easy. All you need is to invoke the makepanda script using the version of Python that you want Panda3D to be built against.

Run makepanda.py with the --help option to see which options are available. Usually, you will want to specify the --everything option (which builds with support for all features for which it detects the prerequisite dependencies) and the --installer option (which produces an installable .deb or .rpm file for you to install, depending on your distribution).

The following command illustrates how to build Panda3D with some common options:

python3 makepanda/makepanda.py --everything --installer --no-egl --no-gles --no-gles2 --no-opencv

You will probably see some warnings saying that it's unable to find several dependency packages. You should determine which ones you want to include in your build and install the respective development packages. You may visit this manual page for an overview of the various dependencies.

If you are on Ubuntu, this command should cover the most frequently used third-party packages:

sudo apt-get install build-essential pkg-config fakeroot python3-dev libpng-dev libjpeg-dev libtiff-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libeigen3-dev libopenal-dev libode-dev libbullet-dev nvidia-cg-toolkit libgtk-3-dev libassimp-dev libopenexr-dev

Once Panda3D has built, you can either install the .deb or .rpm package that is produced, depending on which Linux distribution you are using. For example, to install the package on Debian or Ubuntu, use this:

sudo dpkg -i panda3d*.deb

If you are not using a Linux distribution that supports .deb or .rpm packages, you may have to use the installpanda.py script instead, which will directly copy the files into the appropriate locations on your computer. You may have to run the ldconfig tool in order to update your library cache after installing Panda3D.

Alternatively, you can add the --wheel option, which will produce a .whl file that can be installed into a Python installation using pip.

macOS

On macOS, you will need to download a set of precompiled thirdparty packages in order to compile Panda3D, which can be acquired from here.

After placing the thirdparty directory inside the panda3d source directory, you may build Panda3D using a command like the following:

python makepanda/makepanda.py --everything --installer

You may target a specific minimum macOS version using the --osxtarget flag followed by the release number, eg. 10.9 or 10.14.

If the build was successful, makepanda will have generated a .dmg file in the source directory containing the installer. Simply open it and run the package file in order to install the SDK onto your system.

FreeBSD

Building on FreeBSD is very similar to building on Linux. You will need to install the requisite packages using the system package manager. To install the recommended set of dependencies, you can use this command:

pkg install pkgconf bison png jpeg-turbo tiff freetype2 harfbuzz eigen squish openal opusfile libvorbis libX11 mesa-libs ode bullet assimp openexr

You will also need to choose which version of Python you want to use. Install the appropriate package for it (such as python37 or python38) and run the makepanda script with your chosen Python version:

python3.7 makepanda/makepanda.py --everything --installer --no-egl --no-gles --no-gles2

If successful, this will produce a .pkg file in the root of the source directory which you can install using pkg install.

Android

Although it's possible to build Panda3D on an Android device using the termux shell, the recommended route is to cross-compile .whl files using the SDK and NDK, which can then be used by the build_apps command to build a Python application into an .apk or .aab bundle. You will need to get the latest thirdparty packages, which can be obtained from the artifacts page of the last successful run here:

https://github.com/rdb/panda3d-thirdparty/actions?query=branch%3Amain+is%3Asuccess+event%3Apush

This does not include Python at the moment, which can be extracted from this archive instead.

These commands show how to compile wheels for the supported Android ABIs:

export ANDROID_SDK_ROOT=/home/rdb/local/android
python3.8 makepanda/makepanda.py --everything --outputdir built-droid-arm64 --arch arm64 --target android-21 --threads 6 --wheel
python3.8 makepanda/makepanda.py --everything --outputdir built-droid-armv7a --arch armv7a --target android-19 --threads 6 --wheel
python3.8 makepanda/makepanda.py --everything --outputdir built-droid-x86_64 --arch x86_64 --target android-21 --threads 6 --wheel
python3.8 makepanda/makepanda.py --everything --outputdir built-droid-x86 --arch x86 --target android-19 --threads 6 --wheel

It is now possible to use the generated wheels with build_apps, as explained on this page:

https://discourse.panda3d.org/t/deployment-for-android/28226

Running Tests

Install PyTest and run the pytest command. If you have not installed Panda3D, you will need to configure your environment by pointing the PYTHONPATH variable at the built directory. On Linux, you will also need to point the LD_LIBRARY_PATH variable at the built/lib directory.

As a convenience, you can alternatively pass the --tests option to makepanda.

Reporting Issues

If you encounter any bugs when using Panda3D, please report them in the bug tracker. This is hosted at:

https://github.com/panda3d/panda3d/issues

Make sure to first use the search function to see if the bug has already been reported. When filling out a bug report, make sure that you include as much information as possible to help the developers track down the issue, such as your version of Panda3D, operating system, architecture, and any code and models that are necessary for the developers to reproduce the issue.

If you're not sure whether you've encountered a bug, feel free to ask about it in the forums or the IRC channel first.

Supporting the Project

If you would like to support the project financially, visit our campaign on OpenCollective. Your contributions help us accelerate the development of Panda3D.

For the list of backers, see the BACKERS.md file or visit the Sponsors page on our web site. Thank you to everyone who has donated!

panda3d's People

Contributors

beiyang avatar bluekyu avatar cfsworks avatar dangerousyams avatar darktohka avatar darrenr555 avatar deflected avatar drwrose avatar el-dee avatar enn0x avatar eswartz avatar fireclawthefox avatar gyedo avatar joehager avatar jparise avatar jyelon avatar kpatelpro avatar miangraham avatar mikechristel avatar moguri avatar nthparameter avatar rdb avatar redmondurbino avatar samirnaik avatar shochet avatar tobspr avatar treamology avatar wmokiishi avatar zhaohuang avatar zpavlov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

panda3d's Issues

Can't find libGL after updates

After updating from Debian 9 to Debian 10 (Kernel 4.8 to 4.11) and updating NVidia driver to 375.66, the next restart makeDefaultPipe() fails with

Unable to load: libGL.so.1

Although I can still find it in

libGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libGL.so

I'm running Panda3D version 1.10.0.dev1142 on Python 3.6.1.
libgl-mesa-glx 13.0.6-1 + b2

Segfault in GraphicsEngine::cull_to_bins() when using shadow casters

The supplied zip file contains a Python script, BAM file, and textures. Running the Python script will result in a segfault (back trace below). I do not know when the segfaults started (i.e., which commit), but it is reproducible with the current master branch. It looks like I need at least two models visible by a camera and a shadow caster to be able to reproduce the crash. The multi-threaded render pipeline is not being used (although, using it does result in the well known hang).

OS: Arch Linux 64bit
GPU: Nivida GTX 970 (Proprietary Nvidia drivers)

shadow_crash.zip

Back trace:

#0  0x00007ffff448b4ad in GraphicsEngine::cull_to_bins (this=0x555555b3ab50, wlist=..., current_thread=0x5555558887a0) at panda/src/display/graphicsEngine.cxx:1397
#1  0x00007ffff44884dc in GraphicsEngine::WindowRenderer::do_frame (this=0x555555b3ac08, engine=0x555555b3ab50, current_thread=0x5555558887a0) at panda/src/display/graphicsEngine.cxx:2381
#2  0x00007ffff4487426 in GraphicsEngine::render_frame (this=0x555555b3ab50) at panda/src/display/graphicsEngine.cxx:779
#3  0x00007ffff58ce1aa in Dtool_GraphicsEngine_render_frame_517 (self=0x7ffff6a5c8c8) at built/tmp/libp3display_igate.cxx:21005
#4  0x00007ffff7420a6a in _PyCFunction_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#5  0x00007ffff741e82a in ?? () from /usr/lib/libpython3.6m.so.1.0
#6  0x00007ffff73bc2ea in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#7  0x00007ffff741ddba in _PyFunction_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#8  0x00007ffff73e1dce in _PyObject_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#9  0x00007ffff73e29d1 in _PyObject_Call_Prepend () from /usr/lib/libpython3.6m.so.1.0
#10 0x00007ffff73e2abb in PyObject_Call () from /usr/lib/libpython3.6m.so.1.0
#11 0x00007ffff5e1d462 in PythonThread::call_python_func (function=0x7ffff6a61bc8, args=0x7ffff69f5c50) at panda/src/pipeline/pythonThread.cxx:137
#12 0x00007ffff5e20883 in PythonTask::do_python_task (this=0x7fffe76ed690) at panda/src/event/pythonTask.cxx:404
#13 0x00007ffff5e207f5 in PythonTask::do_task (this=0x7fffe76ed690) at panda/src/event/pythonTask.cxx:384
#14 0x00007ffff44ff7ec in AsyncTask::unlock_and_do_task (this=0x7fffe76ed690) at panda/src/event/asyncTask.cxx:393
#15 0x00007ffff450363b in AsyncTaskChain::service_one_task (this=0x555555b3a2c0, thread=0x0) at panda/src/event/asyncTaskChain.cxx:667
#16 0x00007ffff450268d in AsyncTaskChain::do_poll (this=0x555555b3a2c0) at panda/src/event/asyncTaskChain.cxx:1176
#17 0x00007ffff45088e3 in AsyncTaskManager::poll (this=0x555555917d50) at panda/src/event/asyncTaskManager.cxx:488
#18 0x00007ffff590ef71 in Dtool_AsyncTaskManager_poll_128 (self=0x7fffec5ff238) at built/tmp/libp3event_igate.cxx:4033
#19 0x00007ffff7420a6a in _PyCFunction_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#20 0x00007ffff741e82a in ?? () from /usr/lib/libpython3.6m.so.1.0
#21 0x00007ffff73bc2ea in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#22 0x00007ffff741e34a in ?? () from /usr/lib/libpython3.6m.so.1.0
#23 0x00007ffff741e8ee in ?? () from /usr/lib/libpython3.6m.so.1.0
#24 0x00007ffff73bc2ea in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#25 0x00007ffff741d48d in ?? () from /usr/lib/libpython3.6m.so.1.0
#26 0x00007ffff741e571 in ?? () from /usr/lib/libpython3.6m.so.1.0
#27 0x00007ffff741e8ee in ?? () from /usr/lib/libpython3.6m.so.1.0
#28 0x00007ffff73bc2ea in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#29 0x00007ffff741e34a in ?? () from /usr/lib/libpython3.6m.so.1.0
#30 0x00007ffff741e8ee in ?? () from /usr/lib/libpython3.6m.so.1.0
#31 0x00007ffff73bc2ea in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#32 0x00007ffff741eda7 in PyEval_EvalCodeEx () from /usr/lib/libpython3.6m.so.1.0
#33 0x00007ffff73bbfeb in PyEval_EvalCode () from /usr/lib/libpython3.6m.so.1.0
#34 0x00007ffff748d682 in ?? () from /usr/lib/libpython3.6m.so.1.0
#35 0x00007ffff748fcdd in PyRun_FileExFlags () from /usr/lib/libpython3.6m.so.1.0
#36 0x00007ffff748fec7 in PyRun_SimpleFileExFlags () from /usr/lib/libpython3.6m.so.1.0
#37 0x00007ffff7485e3c in Py_Main () from /usr/lib/libpython3.6m.so.1.0
#38 0x0000555555554cb8 in main ()

MAKE_MAP_PROPERTY and MAKE_SEQ_PROPERTY conflicting in some objects ?

Working with animations, I've noticed that with AnimGroup and PartGroup is impossible to get the sequence of the children, i.e. use code like this:

for child in animGroup.children:
    process(child)
    ...

I think this is because children is defined in both MAKE_MAP_PROPERTY and MAKE_SEQ_PROPERTY, and if this is correct, other objects suffer from similar problems too (GeomVertexFormat, TextureAttrib ...)
If it not the case, which is the correct way to use these properties?

:interrogatedb(error): on latest build (debian 9)

On debian 9.2 (stretch) the latest build issues this interrogatedb's error on any scripts:
:interrogatedb(error): Attempt to use type pvector< unsigned char > which has not yet been defined!
Test code:

from direct.showbase.ShowBase import ShowBase
 
class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

app = MyApp()
app.run()

Problem with off-screen buffers on OSX

Hi,

I am facing issues when creating off-screen buffers on OSX Sierra (makeOutput reutrns None). The error message I get is AttributeError: 'NoneType' object has no attribute 'makeDisplayRegion'.

Here's the code:

winprops = WindowProperties.getDefault()
winprops = WindowProperties(winprops)
winprops.setSize(self.size[0], self.size[1])

fbprops = FrameBufferProperties.getDefault()
fbprops = FrameBufferProperties(fbprops)
fbprops.setRgbColor(1)
fbprops.setColorBits(24)
fbprops.setAlphaBits(8)
fbprops.setDepthBits(1) 

selection = GraphicsPipeSelection.getGlobalPtr()
self.pipe = selection.makeDefaultPipe()

flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRefuseWindow
buf = self.graphicsEngine.makeOutput(self.pipe, 'RGB buffer', 0, fbprops, winprops, flags)

dr = buf.makeDisplayRegion()

I can verify that my Panda3D installation works fine since I am able to run basic examples. Do I need to do any OSX specifc config changes in Config.prc?

Exponent calculation for quaternions appears to be missing from LQuaternionf

The common concept of exponent calculation for quaternions appears to be missing from panda3d.core.LQuaternionf/panda3d.core.LRotationf.

When interpreting a quaternion as a relative rotation (and not an orientation), you could e.g. want to apply only half or only 30% of a rotation. The computation of this appears to be commonly notated with q as base and e.g. 0.5 or 0.3 as exponent: q ** 0.3 (as described here: https://math.stackexchange.com/questions/162863/how-to-get-a-part-of-a-quaternion-e-g-get-half-of-the-rotation-of-a-quaternion/162892#162892 )

However, on the panda3d API reference page http://www.panda3d.org/reference/devel/python/panda3d.core.LQuaternionf the only function even mentioning exponent returns LVecBase4f and not a Quaternion and seems to be inherited from LVecBase4f instead of doing something quaternion-specific.

Is such a functionality implemented somewhere and I'm just missing it? Otherwise, it would be very useful if this could be added.

How do you use the Panda3D Vulkan tree?

I'm still new to anything that is low level. I know Vulkan is better than OpenGl in some cases, but how do I add or use the Vulkan tree?

When I try build it I get this error too

[ 20%] Building C++ object built/tmp/p3gobj_composite2.o
In file included from panda/src/gobj/p3gobj_composite2.cxx:10:0:
panda/src/gobj/shader.cxx:30:26: fatal error: vulkan/spirv.h: No such file or directory
compilation terminated.
Storing dependency cache.
Elapsed Time: 1 sec
The following command returned a non-zero value: g++ -std=gnu++0x -ftemplate-depth-70 -fPIC -c -o built/tmp/p3gobj_composite2.o -Ibuilt/tmp -Ibuilt/include -I/usr/include/eigen3 -Ipanda/src/gobj -fvisibility=hidden -pthread -fno-exceptions -msse2 -fno-strict-aliasing -ffast-math -fno-stack-protector -fno-finite-math-only -O2 -DBUILDING_PANDA panda/src/gobj/p3gobj_composite2.cxx
Build terminated.

I did install the newest version of the VulkanSDK. I don't know what else to do for it.

Another thing I'm running "Mint 18.2 Sonya"

Deploy-ng's importing

This is a minimal program main.py that shows the issue:

import direct.directbase.DirectStart
from xml.etree import cElementTree
from datetime import datetime; datetime.strptime('1970-01-01', '%Y-%m-%d')
run()

This is my requirements.txt:

--pre --extra-index-url https://archive.panda3d.org/branches/deploy-ng
panda3d

This is my setup.py:

from setuptools import setup
 setup(
    name='ng_example',
    options = {
        'build_apps': {
            'gui_apps': {'ng_example': 'main.py'},
            'plugins': ['pandagl'],
            'platforms': ['manylinux1_x86_64'],
        }
    }
)

If I run main.py from SDK it works. If I run a build which has been built with the latest deploy-ng I receive this error from line 2:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
  File "/usr/lib/python2.7/xml/etree/cElementTree.py", line 3, in <module>
    from _elementtree import *
  File "<string>", line 5, in <module>
ImportError: No module named ElementTree

and this error from line 3 (if I comment the line 2):

Traceback (most recent call last):
  File "main.py", line 3, in <module>
ImportError: No module named _strptime

Performance bottleneck in CPU vertex animation

Panda has terrible performance when rendering objects, it could be an issue when merging vertices or even an issue with culling; possibly an issue when iterating through all model info each frame causing render delay.

Strange behavior on start

Hello, I'm new in python and panda, so question may be stupid.
If I first time (after computer is turned on) runs simple project in pycharm

class App(ShowBase):
    pass

if __name__ == '__main__':
    app = App()
    app.run()

and wait about 10 sec, windows is freezing for 5 seconds.
If I run project in second time and more, after 10 seconds windows is freezing again, but I always see "screenshot" of previous thing

Also if I runs in fullscreen, python is crashed with log:

Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
AL lib: (EE) alc_cleanup: 1 device not closed

widows 7
python 3.6
panda 1.10 (through pip)

I can't record it on video. GeforceExperiens ends recording just before start of project, GyazoGif can't see it.
done it on phone https://youtu.be/8Jyr-T43yEM look at time

arabic

how can i add arabic lang if possible?
thanks

egg-palettize: margin option that doesn't sample from the texture

Referencing issue #181, I was having issues with the egg-palettize tool because of the :margin option sampling from the edge of my textures and creating a margin from that resulting in strange effects around the images. Because of this, I've had to manually add transparent and colorless pixels around my images which is tedious and time-consuming.

If an option such as :colorlessmargin or something along those lines could be developed for the egg-palettize tool it would save me plenty of time :)

TypeError decoding NodePath from BAM stream

When trying to unpickle a NodePath from a previously pickled string, I get the following TypeError:

TypeError: py_decode_NodePath_from_bam_stream() takes exactly one argument (2 given)

When using cPickle instead of the regular pickle module, the error report is basically the same, but more verbose:

TypeError: ('py_decode_NodePath_from_bam_stream() takes exactly one argument (2 given)', <built-in function py_decode_NodePath_from_bam_stream>, (<type 'panda3d.core.NodePath'>, 'pbj\x00\n\r\x06\x00\x00\x00\x06\x00*\x00\x01\x00\x05\x00\x00\x00\x00\x01\x00\x00\x00\x91\x00\x00\x00\x004\x00\t\x00PandaNode\x023\x00\x1b\x00TypedWritableReferenceCount\x022\x00\r\x00TypedWritable\x01\x03\x00\x0b\x00TypedObject\x00\x04\x00\x0e\x00ReferenceCount\x00\r\x00\x07\x00Namable\x00\x01\x00\x00\x00\x02\x00\x03\x00\x04\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Z\x00\x00\x00\x02\x9f\x00\x0b\x00RenderState\x01\x9e\x00\x18\x00NodeCachedReferenceCount\x017\x00!\x00CachedTypedWritableReferenceCount\x013\x00\x02\x00\x00\x00\x1c\x00\x00\x00\x02\xae\x00\x0e\x00TransformState\x01\x9e\x00\x03\x00\x05\x00\x01\x00\x19\x00\x00\x00\x02\x9c\x00\r\x00RenderEffects\x013\x00\x04\x00\x00\x00\x01\x00\x00\x00\x01'))

The following code sample demonstrates the problem:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
import pickle


class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)

        np = NodePath("")
        s = pickle.dumps(np, -1)
        loaded_np = pickle.loads(s)


app = MyApp()
app.run()

This issue occurs using version 46c8852 of Panda3D with Python 2.7 64-bit.

man pages installed from .deb package have the wrong permissions

The package panda3d1.9 installed from

deb http://archive.panda3d.org/ubuntu xenial main

sets the permission of the man pages to 600. This prevents normal users from accessing the pages and also prevents mandb from updating the manual page index caches.

Simple fix (while waiting for the package to be changed):

for i in $(dpkg -L panda3d1.9 | grep "/usr/share/man/man1/")
do
  sudo chmod +r $i
done

Panda3D Compilation

On Windows 8 with Visual Studio 10 building Panda3D (latest) statically returns this as an error.

panda3d/dtool/src/dtoolbase/dlmalloc_src.cxx:1678:18: error: unknown type '__forceinline' static FORCEINLINE void* win32mmap(size_t size) { ^ panda3d/dtool/src/dtoolbase/dl malloc_src.cxx:1678:20: error: syntax error, unexpected KW_VOID static FORCEINLINE void* win32mmap(size_t size) { ^~~~ Error parsing file: 'p3dtoolbase_composite1.cxx' Storing dependency cache. Elapsed Time: 2 min 43 sec The following command returned a non-zero value: prebuilt/windows/interrogate.exe -srcdir dtool/src/dtoolbase -Idtool/src/dtoolbase -DCPPPARSER -D__STDC__=1 -D__cplusplus=201103L -DWIN32_VC -DWIN32 -D_WIN32 -D_M_IX86 -D_MSC_VER=1600 -D"__declspec(param)=" -D__cdecl -D_near -D_far -D__near -D__far -D__stdcall -oc built/tmp/libp3dtoolbase_igate.cxx -od built/pandac/input/libp3dtoolbase.in -fnames -string -refcount -assert -python-native -Sbuilt/include/parser-inc -Idtool/src/dtoolbase -Sbuilt/tmp -Sbuilt/include -Sthirdparty/win-python/include -Sthirdparty/win-libs-vc10/eigen\include -Sthirdparty/win-libs-vc10/python/include -Sthirdparty/win-libs-vc10/extras/include -DLINK_ALL_STATIC= -DEIGEN_NO_STATIC_ASSERT= -module panda3d.core -library libp3dtoolbase p3dtoolbase_composite1.cxx p3dtoolbase_composite2.cxx typeHandle.h typeHandle_ext.h typeRegistry.h typedObject.h neverFreeMemory.h

In Actor class, default parent of exposed joint is odd

I found an odd case while building joint tree.
I knew that a exposed joint is parented to the actor instance in Actor class without first node parameter.
However, if a character node (child of Actor) is transformed, then the exposed joint is not affected by the transform.

In looking and gripping example, I moved the character node to (0, 0, 1) and then it is rendered as below.
(self.eve.get_child(0).set_pos(0, 0, 1))

image

And I can fix it by reparenting the exposed joint to the Character node: self.rightHand.reparentTo(self.eve.getChild(0))

OR, by changing the parent node to NodePath of part bundle in Actor class from

node = self.attachNewNode(jointName)

to

node = partDef.partBundleNP.attachNewNode(jointName)

So, I wonder which solution is right.
(or, shouldn't I transform the Character node?)

Dtool_SequenceWrapper compile error

I get this error on the latest commit building statically. From the looks of it, Interrogate does not generate proper wrappers in some fashion.

built/tmp/libp3dtoolbase_igate.cxx(1115) : error C2039: '_setitem_func' : is not
a member of 'Dtool_SequenceWrapper'
c:\users\theclashingfritz\documents\tticodedumper\panda3d\built\include
py_wrappers.h(29) : see declaration of 'Dtool_SequenceWrapper'
built/tmp/libp3dtoolbase_igate.cxx(1169) : error C2039: '_setitem_func' : is not
a member of 'Dtool_SequenceWrapper'
c:\users\theclashingfritz\documents\tticodedumper\panda3d\built\include
py_wrappers.h(29) : see declaration of 'Dtool_SequenceWrapper'
built/tmp/libp3dtoolbase_igate.cxx(2225) : error C2039: '_setitem_func' : is not
a member of 'Dtool_SequenceWrapper'
c:\users\theclashingfritz\documents\tticodedumper\panda3d\built\include
py_wrappers.h(29) : see declaration of 'Dtool_SequenceWrapper'
built/tmp/libp3dtoolbase_igate.cxx(2287) : error C2039: '_setitem_func' : is not
a member of 'Dtool_SequenceWrapper'
c:\users\theclashingfritz\documents\tticodedumper\panda3d\built\include
py_wrappers.h(29) : see declaration of 'Dtool_SequenceWrapper'

textNode generate() is slow

I was looking at PSTATS and noticed that a big chunk of frame time when entering a new area is Generate Text. This is especially relevant in Toontown, where after it loads all the models, the game takes a while to create all the nametags and building signs. Loading into one area, the frame where you actually enter the area, takes about 100ms in showcode, where about 70% of that is by generating text.

Strange margin defects occuring with the egg-palettize tool

I've been using egg-palettize to group textures but there's just one issue I can't solve. Whenever, I create a palette that has the margins option on, it results in a very odd pattern around the texture. All my textures are 24-bit PNGs.

This is my .txa file:

:background 0 0 0 0

* : force-rgba linear clamp_u clamp_v rgb,rgb best
:margin 10

*.egg :

I'm also running it with -opt and using eggs made by egg-texture-cards which has the "-f rgb" option. I've been trying to find a solution for this for quite a while now, if anyone knows why this is occurring a fix/workaround would be appreciated.

ShowBase class lacks any sort of member descriptions or type info

The ShowBase API reference lacks any sort of member descriptions or type info: https://www.panda3d.org/reference/devel/python/direct.showbase.ShowBase.ShowBase

Since this class is so super central (and I very vividly recall ending up on this page very quickly after starting out with Panda3D as a beginner) I think this is a huge shortcoming of the current documentation which should be addressed at least for the important members. This is especially bad since lots of the functionality available through ShowBase members does have extensive documentation, except that people cannot find it through this page since it doesn't have a return type for any of the members which would link to the API reference page that has the details on that specific subsystem / engine component.

Edit: actually some attributes have a short description which I missed, but none of the member methods do and no types are linked to the according type-specific / class-specific detail API reference

On fullscreen, rendering freezes when NVIDIA GeForce Experience is used

I found a issue that rendering window freezes using NVIDIA GeForce Experience.
(This issue does not happen in my simple OpenGL app using GLFW.)

This issue happens when fullscreen mode and NVIDIA Geforce Experience are used.
The rendering window is freezing after 5~7 seconds using Overlay in Game option.
If the option is off, then the freezing disappear.

I think that the issue may be caused by recording and overlay feature in GeForce Experience.
In old drivers, this issue does not exist, but freezing happens after game recording is started.

I tested the issue in the following conditions:

  • Windows 10 64-bit
  • Panda3D Windows x64 v1.9.4, master commit
  • NVIDIA 385.69, 387.92, 388.31 drivers
  • NVIDIA 980Ti, 1080, 1080Ti

Collision into OdeTriMesh collision objects no longer works

I've got a problem with Panda3D after 1.9.3 and OdeTriMesh collision objects. Objects colliding into the OdeTriMesh simply pass through each other with almost no interaction. Actually, it sometimes collides a little bit; most of the cubes fall straight through but one or two will might interact momentarily. The modified example (from the Panda3D manual) works very nicely on 1.9.3 and earlier (haven't tested it yet with 1.9.4.)

The model referenced in the code can be downloaded from here.

from direct.directbase import DirectStart
from panda3d.ode import OdeWorld, OdeSimpleSpace, OdeJointGroup
from panda3d.ode import OdeBody, OdeMass, OdeBoxGeom, OdePlaneGeom
from panda3d.core import BitMask32, CardMaker, Vec4, Quat
from random import randint, random
import math
from pandac.PandaModules import OdeTriMeshData, OdeTriMeshGeom, Point3, Mat4

# Setup our physics world
world = OdeWorld()
world.setGravity(0, 0, -9.81)
 
# The surface table is needed for autoCollide
world.initSurfaceTable(1)
world.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002)
 
# Create a space and add a contactgroup to it to add the contact joints
space = OdeSimpleSpace()
space.setAutoCollideWorld(world)
contactgroup = OdeJointGroup()
space.setAutoCollideJointGroup(contactgroup)
 
# Load the box
box = loader.loadModel("box")
# Make sure its center is at 0, 0, 0 like OdeBoxGeom
box.setPos(-.5, -.5, -.5)
box.flattenLight() # Apply transform
box.setTextureOff()
 
# Add a random amount of boxes
boxes = []
for i in range(randint(15, 30)):
  # Setup the geometry
  boxNP = box.copyTo(render)
  boxNP.setPos(randint(-10, 10), randint(-10, 10), 10 + random())
  boxNP.setColor(random(), random(), random(), 1)
  boxNP.setHpr(randint(-45, 45), randint(-45, 45), randint(-45, 45))
  # Create the body and set the mass
  boxBody = OdeBody(world)
  M = OdeMass()
  M.setBox(5, 1, 1, 1)
  boxBody.setMass(M)
  boxBody.setPosition(boxNP.getPos(render))
  boxBody.setQuaternion(boxNP.getQuat(render))
  # Create a BoxGeom
  boxGeom = OdeBoxGeom(space, 1, 1, 1)
  boxGeom.setCollideBits(BitMask32(0x00000002))
  boxGeom.setCategoryBits(BitMask32(0x00000001))
  boxGeom.setBody(boxBody)
  boxes.append((boxNP, boxBody))
 
# Add a plane to collide with
# cm = CardMaker("ground")
# cm.setFrame(-20, 20, -20, 20)
# ground = render.attachNewNode(cm.generate())
# ground.setPos(0, 0, 0); ground.lookAt(0, 0, -1)
# groundGeom = OdePlaneGeom(space, Vec4(0, 0, 1, 0))
# groundGeom.setCollideBits(BitMask32(0x00000001))
# groundGeom.setCategoryBits(BitMask32(0x00000002))

tray_mod = loader.loadModel('tray.egg')
tray_mod = tray_mod.find('**/tray')
tray_mod.reparentTo(render)
cat=BitMask32(0x00000001)
col=BitMask32(0x00000002)
objdata = OdeTriMeshData(tray_mod, True)
tray_geom = OdeTriMeshGeom(space, objdata)
tray_body = OdeBody(world)
tray_body.setGravityMode(0)
tray_mass = OdeMass()
minDim, maxDim = tray_mod.getTightBounds()
tray_dimms = Point3(maxDim - minDim)
tray_mass.setBox(1, tray_dimms.getX(), tray_dimms.getY(), tray_dimms.getZ())
tray_body.setMass(tray_mass)
tray_body.setPosition(tray_mod.getPos(render))
tray_body.setQuaternion(tray_mod.getQuat(render))
tray_geom.setBody(tray_body)
boxes.append((tray_mod, tray_body))

# Set the camera position
base.disableMouse()
base.camera.setPos(10, -10, 40)
base.camera.lookAt(0, 0, 0)

# The task for our simulation
def simulationTask(task):
  space.autoCollide() # Setup the contact joints
  # Step the simulation and set the new positions
  world.quickStep(globalClock.getDt())
  for np, body in boxes:
    np.setPosQuat(render, body.getPosition(), Quat(body.getQuaternion()))
  contactgroup.empty() # Clear the contact joints
  return task.cont

# Wait a split second, then start the simulation
taskMgr.doMethodLater(0.5, simulationTask, "Physics Simulation")

run()

Setting threading-model /Draw or Cull/Draw while using realtime shadows with shadow cameras will freeze panda3d

Setting threading-model /Draw or Cull/Draw will freeze panda3d for me after a few seconds.
Edit: as pointed out below, I do indeed use light.setShadowCaster() which seems to be related to this.

This is how it looks like in gdb:

(gdb) thread apply all bt

Thread 4 (Thread 0x7fa849ef0700 (LWP 19159)):
#0  0x00007fa871a0181b in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007fa850fbb158 in pa_threaded_mainloop_wait () from /lib64/libpulse.so.0
#2  0x00007fa8514257ef in ALCpulsePlayback_mixerProc () from /lib64/libopenal.so.1
#3  0x00007fa8514294e7 in althrd_starter () from /lib64/libopenal.so.1
#4  0x00007fa8719fb36d in start_thread () from /lib64/libpthread.so.0
#5  0x00007fa871016b8f in clone () from /lib64/libc.so.6

Thread 3 (Thread 0x7fa84e6f1700 (LWP 19158)):
#0  0x00007fa87100aa9d in poll () from /lib64/libc.so.6
#1  0x00007fa850fbab71 in poll_func () from /lib64/libpulse.so.0
#2  0x00007fa850fac530 in pa_mainloop_poll () from /lib64/libpulse.so.0
#3  0x00007fa850facbc0 in pa_mainloop_iterate () from /lib64/libpulse.so.0
#4  0x00007fa850facc50 in pa_mainloop_run () from /lib64/libpulse.so.0
#5  0x00007fa850fbaab9 in thread () from /lib64/libpulse.so.0
#6  0x00007fa850d5a078 in internal_thread_func () from /usr/lib64/pulseaudio/libpulsecommon-10.0.so
#7  0x00007fa8719fb36d in start_thread () from /lib64/libpthread.so.0
#8  0x00007fa871016b8f in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7fa85a39d700 (LWP 19154)):
#0  0x00007fa871a04fad in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007fa8719fde88 in pthread_mutex_lock () from /lib64/libpthread.so.0
#2  0x00007fa865ef17a9 in ReMutexPosixImpl::acquire() () from /usr/lib64/panda3d/libpanda.so.1.10
#3  0x00007fa8660837f9 in GraphicsEngine::get_threading_model() const () from /usr/lib64/panda3d/libpanda.so.1.10
#4  0x00007fa86608ef8a in GraphicsEngine::make_output(GraphicsPipe*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, FrameBufferProperties const&, WindowProperties const&, int, GraphicsStateGuardian*, GraphicsOutput*) ()
   from /usr/lib64/panda3d/libpanda.so.1.10
#5  0x00007fa8660ae662 in GraphicsStateGuardian::make_shadow_buffer(NodePath const&, GraphicsOutputBase*) ()
   from /usr/lib64/panda3d/libpanda.so.1.10
#6  0x00007fa8660af19a in GraphicsStateGuardian::get_shadow_map(NodePath const&, GraphicsOutputBase*) () from /usr/lib64/panda3d/libpanda.so.1.10
#7  0x00007fa8660b4301 in GraphicsStateGuardian::fetch_specified_texture(Shader::ShaderTexSpec&, SamplerState&, int&) ()
   from /usr/lib64/panda3d/libpanda.so.1.10
#8  0x00007fa85bf1d9ae in GLShaderContext::update_shader_texture_bindings(ShaderContext*) () from /usr/lib64/panda3d/libpandagl.so
#9  0x00007fa85bf20d18 in GLGraphicsStateGuardian::do_issue_texture() () from /usr/lib64/panda3d/libpandagl.so
#10 0x00007fa85bf2ada5 in GLGraphicsStateGuardian::set_state_and_transform(RenderState const*, TransformState const*) ()
   from /usr/lib64/panda3d/libpandagl.so
#11 0x00007fa865f83787 in CullBinFixed::draw(bool, Thread*) () from /usr/lib64/panda3d/libpanda.so.1.10
#12 0x00007fa865eda9a3 in CullResult::draw(Thread*) () from /usr/lib64/panda3d/libpanda.so.1.10
#13 0x00007fa86609167d in GraphicsEngine::do_draw(GraphicsOutput*, GraphicsStateGuardian*, DisplayRegion*, Thread*) ()
   from /usr/lib64/panda3d/libpanda.so.1.10
#14 0x00007fa866091977 in GraphicsEngine::draw_bins(ov_set<PointerTo<GraphicsOutput>, IndirectLess<GraphicsOutput>, pvector<PointerTo<GraphicsOutput> > > const&, Thread*) () from /usr/lib64/panda3d/libpanda.so.1.10
#15 0x00007fa866093846 in GraphicsEngine::WindowRenderer::do_frame(GraphicsEngine*, Thread*) () from /usr/lib64/panda3d/libpanda.so.1.10
#16 0x00007fa86609541b in GraphicsEngine::RenderThread::thread_main() () from /usr/lib64/panda3d/libpanda.so.1.10
#17 0x00007fa8660c5ff0 in ThreadPosixImpl::root_func(void*) () from /usr/lib64/panda3d/libpanda.so.1.10
#18 0x00007fa8719fb36d in start_thread () from /lib64/libpthread.so.0
---Type <return> to continue, or q <return> to quit---
#19 0x00007fa871016b8f in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7fa87236a700 (LWP 19144)):
#0  0x00007fa871a04fad in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007fa8719fde13 in pthread_mutex_lock () from /lib64/libpthread.so.0
#2  0x00007fa865ec12c9 in MutexPosixImpl::acquire() () from /usr/lib64/panda3d/libpanda.so.1.10
#3  0x00007fa8660940d1 in GraphicsEngine::render_frame() () from /usr/lib64/panda3d/libpanda.so.1.10
#4  0x00007fa866d7210c in Dtool_GraphicsEngine_render_frame_515(_object*, _object*) ()
   from /usr/lib64/python3.6/site-packages/panda3d/core.cpython-36m-x86_64-linux-gnu.so
#5  0x00007fa871d9713a in _PyCFunction_FastCallDict () from /lib64/libpython3.6m.so.1.0
#6  0x00007fa871d9e4ba in call_function () from /lib64/libpython3.6m.so.1.0
#7  0x00007fa871ddb61a in _PyEval_EvalFrameDefault () from /lib64/libpython3.6m.so.1.0
#8  0x00007fa871d2d12a in _PyFunction_FastCallDict () from /lib64/libpython3.6m.so.1.0
#9  0x00007fa871d2d81e in _PyObject_FastCallDict () from /lib64/libpython3.6m.so.1.0
#10 0x00007fa871d37451 in _PyObject_Call_Prepend () from /lib64/libpython3.6m.so.1.0
#11 0x00007fa871d2dc3b in PyObject_Call () from /lib64/libpython3.6m.so.1.0
#12 0x00007fa86707775d in PythonThread::call_python_func(_object*, _object*) ()
   from /usr/lib64/python3.6/site-packages/panda3d/core.cpython-36m-x86_64-linux-gnu.so
#13 0x00007fa86707ac4e in PythonTask::do_python_task() () from /usr/lib64/python3.6/site-packages/panda3d/core.cpython-36m-x86_64-linux-gnu.so
#14 0x00007fa86707b398 in PythonTask::do_task() () from /usr/lib64/python3.6/site-packages/panda3d/core.cpython-36m-x86_64-linux-gnu.so
#15 0x00007fa8660cdc3d in AsyncTask::unlock_and_do_task() () from /usr/lib64/panda3d/libpanda.so.1.10
#16 0x00007fa8660d5a2a in AsyncTaskChain::service_one_task(AsyncTaskChain::AsyncTaskChainThread*) () from /usr/lib64/panda3d/libpanda.so.1.10
#17 0x00007fa8660d70c1 in AsyncTaskChain::do_poll() () from /usr/lib64/panda3d/libpanda.so.1.10
#18 0x00007fa8660d7861 in AsyncTaskManager::poll() () from /usr/lib64/panda3d/libpanda.so.1.10
#19 0x00007fa866da8143 in Dtool_AsyncTaskManager_poll_128(_object*, _object*) ()
   from /usr/lib64/python3.6/site-packages/panda3d/core.cpython-36m-x86_64-linux-gnu.so
#20 0x00007fa871d9713a in _PyCFunction_FastCallDict () from /lib64/libpython3.6m.so.1.0
#21 0x00007fa871d9e4ba in call_function () from /lib64/libpython3.6m.so.1.0
#22 0x00007fa871ddb61a in _PyEval_EvalFrameDefault () from /lib64/libpython3.6m.so.1.0
#23 0x00007fa871d60c5a in fast_function () from /lib64/libpython3.6m.so.1.0
#24 0x00007fa871d9e57e in call_function () from /lib64/libpython3.6m.so.1.0
#25 0x00007fa871ddb61a in _PyEval_EvalFrameDefault () from /lib64/libpython3.6m.so.1.0
#26 0x00007fa871d2c81d in _PyEval_EvalCodeWithName () from /lib64/libpython3.6m.so.1.0
#27 0x00007fa871d60e81 in fast_function () from /lib64/libpython3.6m.so.1.0
#28 0x00007fa871d9e57e in call_function () from /lib64/libpython3.6m.so.1.0
#29 0x00007fa871ddb61a in _PyEval_EvalFrameDefault () from /lib64/libpython3.6m.so.1.0
#30 0x00007fa871d60c5a in fast_function () from /lib64/libpython3.6m.so.1.0
#31 0x00007fa871d9e57e in call_function () from /lib64/libpython3.6m.so.1.0
#32 0x00007fa871ddb61a in _PyEval_EvalFrameDefault () from /lib64/libpython3.6m.so.1.0
#33 0x00007fa871dab427 in PyEval_EvalCodeEx () from /lib64/libpython3.6m.so.1.0
#34 0x00007fa871dac18b in PyEval_EvalCode () from /lib64/libpython3.6m.so.1.0
#35 0x00007fa871e33922 in run_mod () from /lib64/libpython3.6m.so.1.0
#36 0x00007fa871e3457d in PyRun_FileExFlags () from /lib64/libpython3.6m.so.1.0
#37 0x00007fa871e367a7 in PyRun_SimpleFileExFlags () from /lib64/libpython3.6m.so.1.0
#38 0x00007fa871e377a3 in Py_Main () from /lib64/libpython3.6m.so.1.0
#39 0x000055d7c3dd9cf5 in main ()
(gdb)

OSX: Latest version not compatible with sierra 10.12.6

image

When I tried installing the downloaded runtime from here, it gives the error: "Incompatible with your system, would you like to try to install anyway", which then fails.

SDK installs OK, and I can install via pip.

python my-app.py runs ok, but I'm trying to build a my-app.p3d file to test distribution.

> locate packp3d
/Developer/Panda3D/direct/p3d/ppackage.py
/Users/Tavurth/projects/panda3d/panda3d-1.9.4/built/direct/p3d/ppackage.py
/Users/Tavurth/projects/panda3d/panda3d-1.9.4/direct/src/p3d/ppackage.py
/usr/local/lib/python3.6/site-packages/direct/p3d/__pycache__/ppackage.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/direct/p3d/ppackage.py

Upon running one of these files with python, I get the message:

This script must be run using a version of Panda3D that has been built
for distribution.  Try using ppackage.p3d or packp3d.p3d instead.
If you are running this script for development purposes, you may also
set the Config variable panda-package-host-url to the URL you expect
to download these contents from (for instance, a file:// URL).

Any ideas on how I can build a p3d file on this version?

TextureAttrib of loaded .bam file randomly ignores off-stage

When loading a .bam file containing a hierarchy of 2 GeomNodes, where the child GeomNode has a TextureAttrib that turns off specific texture stages used by the parent GeomNode, it can happen (randomly, it seems) that one of the stages is set to "on" for the child - at least in the net render state, even though in the local render state it is correctly turned off.

So if the texture stages used for the parent GeomNode are called "stage1" and "stage2", then the expected results for the child GeomNode would be:

child texture stages off: ["stage1", "stage2"]
child texture stages on: []

And while that is indeed always the case for the local render state, it can happen that for the net render state I get this:

child texture stages off: []
child texture stages on: ["stage2"] # this should be empty

Related topic containing more info and sample code can be found here.

As mentioned before, it can take a few runs of the code to see different results.

No longer able to retrieve depth texture from buffer

Some months ago I made this code snippet to use the depth buffer instead of a CollisionRay to get the coordinates of a point on a model under the mouse cursor.
With more recent versions of Panda it doesn't work anymore, as it seems that the depth texture assigned to the buffer gets converted to a color texture.

Here is some code to clarify the problem:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase

loadPrcFileData("", "depth-bits 24")


class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)

        depth_tex = Texture("depth_texture")
        depth_tex.set_format(Texture.F_depth_component)
        fbp = FrameBufferProperties()
        fbp.set_depth_bits(24)
        buffer = self.win.make_texture_buffer("buffer", 1, 1, depth_tex, to_ram=True, fbp=fbp)
        self.graphicsEngine.render_frame()
        tex_formats = {Texture.F_rgb: "F_rgb", Texture.F_depth_component: "F_depth_component"}
        print "Texture format:", tex_formats[depth_tex.get_format()]


app = MyApp()
app.run()

The output is:

Texture format: F_rgb

With older Panda versions, it is as expected:

Texture format: F_depth_component

Perhaps I should use a different way to access the depth buffer texture? I already tried calling GraphicsOutput.add_render_texture(depth_tex, GraphicsOutput.RTM_copy_ram, DrawableRegion.RTP_depth) instead of make_texture_buffer, and Texture.set_match_framebuffer_format(True), as well as FrameBufferProperties.setup_depth_texture(depth_tex), but the results are always the same. Replacing F_depth_component with F_depth_component24 doesn't help either.

This happens using version 9bfc425 of Panda3D (Python 2.7, 64-bit).

get image data from ram image

After this code, I get the 2d texture data
base.graphicsEngine.renderFrame()
tex = base.win.getScreenshot()
2d_texture
2-d, 128 x 128 pixels, each 4 bytes, rgba
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 65536 bytes in ram, compression off

But
tex.getRamImageAs("RGB").getData()
or
tex.getRamImageAs("RGBA").getData()
or
tex.getRamImage().getData()
doesn't work.

Error Message is here.

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

My Panda3d Version is panda3d (1.10.0.dev1189) and python 3.6.2

Running my panda3d project on Fedora 27 will spam AL lib: (WW) AlSetError message

Running my panda3d project on Fedora 27 will spam the following message into the terminal non-stop:

AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003
AL lib: (WW) alSetError: Error generated on context 0x558ba9194ad0, code 0xa003

Everything else works fine (including audio as far as I can tell without any noticeable distortion) so it's not a big deal breaker, but it does get in the way of debugging and reading messages I actually care about.

Setting array of shader input results TypeError

Following script and it's output clearly states the problem, using Panda3d 1.9.4:

#!/usr/bin/env python
from direct.showbase.ShowBase import ShowBase
from panda3d.core import NodePath, PTAFloat, Shader

v_shader = """
uniform float foo[8];

void main() {
}
"""

f_shader = """
void () main {
}
"""


class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        array = [0.5 / (i + 1) for i in range(8)]
        array_sh = Shader.make(Shader.SL_GLSL, v_shader, f_shader)

        self.array_np = NodePath('arrayNode')
        self.array_np.set_shader(array_sh)

        try:
            self.fail(array)
        except Exception as e:
            print e
            try:
                self.success(array)
            except Exception as e:
                print e

    def fail(self, arr):
        print "I'm a failure"
        self.array_np.set_shader_input('foo', arr)

    def success(self, arr):
        print "I'm the winner"
        pta = PTAFloat()
        for v in arr:
            pta.push_back(v)
        self.array_np.set_shader_input('foo', pta)

if __name__ == '__main__':
    app = MyApp()
    app.run()

results (bold pars are the error stream):

Known pipe types:
glxGraphicsPipe
(all display modules loaded.)

I'm a failure
TypeError: PointerToArray.push_back() argument 1 must be UnalignedLMatrix4f, not float
TypeError: Element 0 in sequence passed to PointerToArray constructor could not be added
TypeError: Element 0 in sequence passed to PointerToArray constructor could not be added
TypeError: Element 0 in sequence passed to PointerToArray constructor could not be added
TypeError: PointerToArray.push_back() argument 1 must be UnalignedLVecBase4i, not float
TypeError: PointerToArray.push_back() argument 1 must be UnalignedLVecBase4f, not float
TypeError: PointerToArray.push_back() argument 1 must be LVecBase3i, not float
TypeError: PointerToArray.push_back() argument 1 must be LVecBase3f, not float
TypeError: PointerToArray.push_back() argument 1 must be LVecBase2i, not float
TypeError: PointerToArray.push_back() argument 1 must be LVecBase2f, not float
TypeError: PointerToArray.push_back() argument 1 must be LMatrix3f, not float

Element 0 in sequence passed to PointerToArray constructor could not be added
I'm the winner

Virtual File System issues

Panda seems to have issues when you have complex model-path prc settings. I have a model folder structure that looks similar to this

- resources
  - pack1
  - pack2
  - pack3
  - pack4
  - pack5

prc:

model-path resources
model-path resources/pack1
model-path resources/pack2
model-path resources/pack3
model-path resources/pack4
model-path resources/pack5

It is split up to help make packing for distribution easier on file size. However various files will not be found by the vfs. There is also presence of an assertion relating to the directories in dtool/src/dSearchPath.cxx on line 262

n < _directories.size()

Getting weird error "Assertion failed: Shader input is not present." which doesn't really help figuring out what input is missing

I am getting the weird error "Assertion failed: Shader input is not present." which doesn't really help figuring out what input is missing. i managed to nail it down to the following code to reproduce (requires "test.egg" model of any sort present which can be loaded into the scene so the render actually renders the shader):

#!/usr/bin/python3

from panda3d.core import KeyboardButton, Shader,\
    Texture, Vec3, PythonCallbackObject, loadPrcFileData,\
    PointLight
from direct.showbase.ShowBase import ShowBase

loadPrcFileData('', "gl-version 4 0")

base = ShowBase()

shader = Shader.make(Shader.SLGLSL,
"""
#version 330

void main() {
}
""", """
#version 330

struct p3d_LightSourceParameters {
  vec4 position;
  vec4 diffuse;
  vec4 specular;
  vec3 attenuation;
  vec3 spotDirection;
  float spotCosCutoff;
  float spotExponent;
  sampler2DShadow shadowMap;
  mat4 shadowMatrix;
};
uniform p3d_LightSourceParameters shadowLight0;

out vec4 p3d_FragColor;

void main() {
  p3d_FragColor.rgb += shadowLight0.position.xyz;
}
""")

base.render.set_shader(shader)

_l = PointLight("Shadowless point light")
l = base.render.attach_new_node(_l)
l.node().set_scene(base.render)
l.node().set_active(True)
base.render.set_light(l)
base.render.setShaderInput('shadowLight0', l)

m = base.loader.loadModel("test.egg")
m.reparentTo(base.render)

base.run()

I suspect something about the struct members might be wrong, but without a better error message it is really hard to tell what the issue is..

TL;DR: would it be possible to provide a better error message here? That would be neat!

Differences in texture blending with ShaderGenerator vs. fixed-function pipeline

In short, the problematic settings seem to be the following:

  1. NodePath color scale (affects M_modulate, M_replace, M_blend_color_scale, M_add, M_decal, CM_replace, CM_add, CM_add_signed; not sure about CM_subtract and CM_interpolate);
  2. CM_subtract;
  3. CM_interpolate;
  4. CS_constant_color_scale;
  5. CO_one_minus_src_color;
  6. rgb scale;

while CM_dot3_rgb and CM_dot3_rgba raise an assertion error:

AssertionError: shader != nullptr at line 1565 of c:\buildslave\sdk-windows-i386\build\panda\src\pgraphnodes\shaderGenerator.cxx

Here are some example settings that cause different results when using the ShaderGenerator, compared to those when using the fixed-function pipeline; you can test these settings with the code sample given below.

  1. NodePath color scale:

stage 1: M_modulate
stage 2: M_blend_color_scale with color scale white

stage 1: M_modulate
stage 2: M_add with color scale (1., .3, .1, 1.)

  1. CM_subtract:

stage 1: M_modulate
stage 2: CM_subtract, CS_texture, CO_src_color, CS_previous, CO_src_color

  1. CM_interpolate:

stage 1: M_modulate
stage 2: CM_interpolate, CS_texture, CO_src_color, CS_previous, CO_src_color, CS_previous, CO_src_color

  1. CS_constant_color_scale:

stage 1: M_modulate
stage 2: CM_modulate, CS_constant_color_scale, CO_src_color, CS_previous, CO_src_color

  1. CO_one_minus_src_color:

stage 1: M_modulate
stage 2: CM_modulate, CS_texture, CO_one_minus_src_color, CS_previous, CO_src_color

stage 1: M_add
stage 2: CM_modulate, CS_previous, CO_src_color, CS_texture, CO_one_minus_src_color

  1. rgb scale:

stage 1: M_modulate
stage 2: CM_add_signed, CS_texture, CO_src_color, CS_previous, CO_src_color
stage 2 rgb scale: 2

Here is a code sample that should allow for easy testing of the various combinations of blending modes, combine modes, sources and operands:

from panda3d.core import *
from direct.gui.OnscreenText import OnscreenText
from direct.gui.DirectGui import *
from direct.showbase.ShowBase import ShowBase
from math import sin, pi


class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)

        self.disable_mouse()

        TS = TextureStage
        self._modes = {
            "M_modulate": TS.M_modulate,
            "M_replace": TS.M_replace,
            "M_blend": TS.M_blend,
            "M_blend_color_scale": TS.M_blend_color_scale,
            "M_add": TS.M_add,
            "M_decal": TS.M_decal,
            "CM_dot3_rgb": TS.CM_dot3_rgb,
            "CM_dot3_rgba": TS.CM_dot3_rgba,
            "CM_modulate": TS.CM_modulate,
            "CM_replace": TS.CM_replace,
            "CM_interpolate": TS.CM_interpolate,
            "CM_add": TS.CM_add,
            "CM_add_signed": TS.CM_add_signed,
            "CM_subtract": TS.CM_subtract
        }
        self._combine_sources = {
            "CS_texture": TS.CS_texture,
            "CS_constant": TS.CS_constant,
            "CS_constant_color_scale": TS.CS_constant_color_scale,
            "CS_primary_color": TS.CS_primary_color,
            "CS_previous": TS.CS_previous
        }
        self._combine_operands = {
            "CO_src_color": TS.CO_src_color,
            "CO_one_minus_src_color": TS.CO_one_minus_src_color
        }

        self._ffp_node = self.render.attach_new_node("fixed_function_pipeline")
        self._ffp_node.set_pos(-2.1, 15., 1.65)
        self._shader_node = self.render.attach_new_node("shader_generator")
        self._shader_node.set_shader_auto()
        self._shader_node.set_pos(2.1, 15., 1.65)

        # Create the texture stages

        self._tex_stages = {}

        # the first texture stage should contain a color gradient
        self._tex_stages["ts1"] = ts1 = TextureStage("layer1")
        ts1.set_color((1., 0., 0., .5))
        ts1.set_sort(0)
        ts1.set_combine_rgb(TextureStage.CM_modulate,
                            TextureStage.CS_texture, TextureStage.CO_src_color,
                            TextureStage.CS_previous, TextureStage.CO_src_color)
        # the second texture stage should contain a checker pattern
        self._tex_stages["ts2"] = ts2 = TextureStage("layer2")
        ts2.set_color((0., 1., 1., .5))
        ts2.set_sort(1)

        self._rgb_scales = {}
        self._mode_ids = {}
        self._combine_source_ids = {}
        self._combine_operand_ids = {}

        for ts_id in ("ts1", "ts2"):
            self._rgb_scales[ts_id] = 1
            self._mode_ids[ts_id] = "M_modulate"
            self._combine_source_ids[ts_id] = ["CS_texture", "CS_previous", "CS_previous"]
            self._combine_operand_ids[ts_id] = ["CO_src_color", "CO_src_color", "CO_src_color"]

        OnscreenText(text="fixed-function pipeline", pos=(-.5, .93), scale=.07)
        OnscreenText(text="shader generator", pos=(.5, .93), scale=.07)

        # Create the color gradient

        w = 256
        h = 256
        w_ = 256
        h_ = 256
        rng = h_ / 3.
        img1 = PNMImage(w, h, 4)
        img1.alpha_fill(1.)

        for x in range(w):

            for y in range(h):

                if 0. <= x < rng:
                    # between red and green
                    b = 0.
                    g = x / rng
                    r = 1. - g
                    factor = 1. + sin(g * pi)
                    r *= factor
                    g *= factor
                elif rng <= x < 2. * rng:
                    # between green and blue
                    r = 0.
                    b = (x - rng) / rng
                    g = 1. - b
                    factor = 1. + sin(b * pi)
                    g *= factor
                    b *= factor
                elif 2. * rng <= x < h:
                    # between blue and red
                    g = 0.
                    r = (x - 2. * rng) / rng
                    b = 1. - r
                    factor = 1. + sin(r * pi)
                    b *= factor
                    r *= factor

                img1.set_xel(x, y, r, g, b)

        img_tmp = PNMImage(w, h, 4)
        img_tmp.fill(.5, .5, .5)

        for y in range(h):

            a = 1. * y / h_

            for x in range(w):
                img_tmp.set_alpha(x, y, a)

        img1.blend_sub_image(img_tmp, 0, 0, 0, 0)

        # Create the checker pattern

        w = 256
        h = 256
        w_ = 256
        h_ = 256
        rng = h_ / 4
        img2 = PNMImage(w, h, 4)
        img2.alpha_fill(1.)

        for x in range(w):

            if (x // rng) % 2:

                for y in range(h):

                    if (y // rng) % 2:
                        # blue
                        b = 1.
                        g = r = 0.
                    else:
                        # red
                        r = 1.
                        b = g = 0.

                    img2.set_xel(x, y, r, g, b)

            else:

                for y in range(h):

                    if (y // rng) % 2:
                        # green
                        g = 1.
                        r = b = 0.
                    else:
                        # white
                        r = b = g = 1.

                    img2.set_xel(x, y, r, g, b)

        # Create the geometry and add textures

        cm = CardMaker("quad")
        cm.set_frame(-2., 2., -2., 2.)
        quads = []
        self._has_color_scale = False

        for node in (self._ffp_node, self._shader_node):
            node.set_transparency(TransparencyAttrib.M_alpha)
            quad = node.attach_new_node(cm.generate())
            tex1 = Texture("layer1")
            tex1.load(img1)
            tex2 = Texture("layer2")
            tex2.load(img2)
            quad.set_texture(ts1, tex1)
            quad.set_texture(ts2, tex2)
            quad.set_color((1., 1., 1., 1.))
            quads.append(quad)

        def toggle_color_scale():

            scale = (1., 1., 1., 1.) if self._has_color_scale else (1., .3, .1, 1.)
            self._has_color_scale = not self._has_color_scale

            for quad in quads:
                quad.set_color_scale(scale)

        DirectButton(text="Toggle color scale", pos=(1.1, 0., -.95), scale=.05,
                     command=toggle_color_scale)

        OnscreenText(text="Stage", pos=(-1.18, -.2), scale=.1)
        OnscreenText(text="Mode", pos=(-.65, -.2), scale=.1)
        OnscreenText(text="Sources", pos=(.05, -.2), scale=.1)
        OnscreenText(text="Operands", pos=(.85, -.2), scale=.1)
        OnscreenText(text="1", pos=(-1.17, -.3), scale=.07)
        OnscreenText(text="2", pos=(-1.17, -.55), scale=.07)
        initial_items = ((0, 4, 4))

        for i in range(2):

            def get_command(ts_id):

                def command(mode_id):
                    self._mode_ids[ts_id] = mode_id

                return command

            ts_id = "ts%d" % (i + 1)

            DirectOptionMenu(
                text="M_modulate", pos=(-1., 0., -.3 - .3 * i), scale=.06,
                items=["M_modulate", "M_replace", "M_blend", "M_blend_color_scale",
                       "M_add", "M_decal", "CM_modulate", "CM_replace", "CM_interpolate",
                       "CM_add", "CM_add_signed", "CM_subtract", "CM_dot3_rgb", "CM_dot3_rgba"],
                initialitem=0, highlightColor=(.65, .65, .65, 1.),
                command=get_command(ts_id), textMayChange=1
            )

            for j in range(3):
     
                def get_command(ts_id, j):
     
                    def command(source_id):
                        self._combine_source_ids[ts_id][j] = source_id
     
                    return command

                DirectOptionMenu(
                    text="CS_texture", pos=(-.3, 0., -.3 - .3 * i - j * .1), scale=.06,
                    items=["CS_texture", "CS_constant", "CS_constant_color_scale",
                           "CS_primary_color", "CS_previous"],
                    initialitem=initial_items[j], highlightColor=(.65, .65, .65, 1.),
                    command=get_command(ts_id, j), textMayChange=1
                )

                def get_command(ts_id, j):
     
                    def command(source_id):
                        self._combine_operand_ids[ts_id][j] = source_id
     
                    return command

                DirectOptionMenu(
                    text="CO_src_color", pos=(.5, 0., -.3 - .3 * i - j * .1), scale=.06,
                    items=["CO_src_color", "CO_one_minus_src_color"],
                    initialitem=0, highlightColor=(.65, .65, .65, 1.),
                    command=get_command(ts_id, j), textMayChange=1
                )

            def get_command(ts_id):

                def command(scale_str):
                    self._rgb_scales[ts_id] = int(scale_str)

                return command

            DirectOptionMenu(
                text="1", pos=(-.4 + .5 * i, 0., -.95), scale=.08,
                items=["1", "2", "4"],
                initialitem=0, highlightColor=(.65, .65, .65, 1.),
                command=get_command(ts_id), textMayChange=1
            )

        OnscreenText(text="RGB scale:", pos=(-1., -.95), scale=.09)
        OnscreenText(text="stage 1", pos=(-.6, -.95), scale=.07)
        OnscreenText(text="stage 2", pos=(-.1, -.95), scale=.07)

        def command():

            for i in range(2):

                ts_id = "ts%d" % (i + 1)

                scale = self._rgb_scales[ts_id]
                self._tex_stages[ts_id].set_rgb_scale(scale)

                mode_id = self._mode_ids[ts_id]
                mode = self._modes[mode_id]

                if mode_id.startswith("M_"):

                    self._tex_stages[ts_id].set_mode(mode)

                else:

                    if mode_id == "CM_replace":
                        source_ids = self._combine_source_ids[ts_id][:1]
                        operand_ids = self._combine_operand_ids[ts_id][:1]
                    elif mode_id == "CM_interpolate":
                        source_ids = self._combine_source_ids[ts_id]
                        operand_ids = self._combine_operand_ids[ts_id]
                    else:
                        source_ids = self._combine_source_ids[ts_id][:2]
                        operand_ids = self._combine_operand_ids[ts_id][:2]

                    sources = [self._combine_sources[source_id]
                               for source_id in source_ids]
                    operands = [self._combine_operands[operand_id]
                                for operand_id in operand_ids]
                    args = sum(zip(sources, operands), ())
                    self._tex_stages[ts_id].set_combine_rgb(mode, *args)

        DirectButton(text="Apply", pos=(.75, 0., -.95), scale=.07, command=command)


app = MyApp()
app.run()

tex_blend_bugs

Testing was done using version 0343dbc of Panda3D on Windows 10 64-bit.

shadergenerator fails to create shaders after f79fbf2

:shader(error): Failed to compile Cg shader created-shader:
(98) : error C1038: declaration of "vtx_tangent" conflicts with previous declaration at (94)
(99) : error C1038: declaration of "vtx_binormal" conflicts with previous declaration at (95)
(100) : error C1038: declaration of "l_tangent" conflicts with previous declaration at (96)
(101) : error C1038: declaration of "l_binormal" conflicts with previous declaration at (97)

and here's the corresponding vshader that failed to compile:
void vshader(
in float4 vtx_texcoord : TEXCOORD0,
out float4 l_texcoord : TEXCOORD0,
in float4 vtx_tangent : TEXCOORD1,
in float4 vtx_binormal : TEXCOORD2,
out float4 l_tangent : TEXCOORD1,
out float4 l_binormal : TEXCOORD2,
in float4 vtx_tangent : TEXCOORD3,
in float4 vtx_binormal : TEXCOORD4,
out float4 l_tangent : TEXCOORD3,
out float4 l_binormal : TEXCOORD4,
uniform float4x4 trans_model_to_view,
out float4 l_eye_position : TEXCOORD5,
uniform float4x4 tpose_view_to_model,
out float4 l_eye_normal : TEXCOORD6,
in float3 vtx_normal : NORMAL,
in float4 vtx_position : POSITION,
out float4 l_position : POSITION,
uniform float4x4 mat_modelproj
) {
l_position = mul(mat_modelproj, vtx_position);
l_eye_position = mul(trans_model_to_view, vtx_position);
l_eye_normal.xyz = normalize(mul((float3x3)tpose_view_to_model, vtx_normal));
l_eye_normal.w = 0;
l_texcoord = vtx_texcoord;
l_tangent.xyz = normalize(mul((float3x3)trans_model_to_view, vtx_tangent.xyz));
l_tangent.w = 0;
l_binormal.xyz = normalize(mul((float3x3)trans_model_to_view, -vtx_binormal.xyz));
l_binormal.w = 0;
}

Vulkan failing to start up at the validation layer

I've compiled static libraries for embedding a Panda3D application with Vulkan support (from the vulkan branch). Whenever I try to start up my program, I'm greeted with this:

Known pipe types:
  TinyWinGraphicsPipe
  TinyOffscreenGraphicsPipe
  wglGraphicsPipe
  VulkanGraphicsPipe
(all display modules loaded.)
:display:windisplay: OS version: 6.2.2.9200
:display:windisplay:
:display:windisplay: max Mhz 2601000000, current Mhz 800000000
:Base: Default graphics pipe is VulkanGraphicsPipe (Vulkan).
:display:vulkandisplay(warning): vkCreateSampler: value of pCreateInfo->anisotropyEnable (167) is neither VK_TRUE nor VK_FALSE
:display:vulkandisplay(warning): vkCreateSampler: value of pCreateInfo->compareEnable (10944877) is neither VK_TRUE nor VK_FALSE
:display:vulkandisplay(error): vkCreateRenderPass: parameter pCreateInfo->flags must be 0. The spec valid usage text states 'flags must be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkRenderPassCreateInfo-flags-zerobitmask)
:display:vulkandisplay(error): vkCreateImageView: value of pCreateInfo->subresourceRange.aspectMask contains flag bits that are not recognized members of VkImageAspectFlagBits
:display:vulkandisplay(error): vkCreateImageView(): Combination depth/stencil image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT and VK_IMAGE_ASPECT_STENCIL_BIT set. The spec valid usage text states 'aspectMask must be a valid combination of VkImageAspectFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageSubresource-aspectMask-parameter)

I am using MSVC 2010 and Windows SDK 7.1. I've also tested with Vulkan SDK versions 1.0.30.0, 1.0.49.0, and 1.0.65.1, linking to vulkan-1.lib in my application (with none working, obviously). In vulkanGraphicsStateGuardian.cxx, pCreateInfo->flags and pCreateInfo->subresourceRange.aspectMask are very clearly valid; any ideas why this might be happening?

Moving panda3d globals outside of builtins

While compiling my application with Cython it hit a snag when trying to locate the variables panda3d adds to the global namespace. I'm pretty sure this is because they are added during runtime so Cython has no clue about their existence during compile time. A simple but ugly workaround is accessing them through the builtins module explicitly e.g. builtins.loader.loadTexture(...) instead of just loader.loadTexture(...).

This made me think, wouldn't it be better to do something like this instead of modifying the python bultins?

from panda3d.globals import loader
loader.loadTexture(...)

It doesn't complicate the application code whatsoever, the only change is having to explicitly import the variable at the top of the file, everything else stays as is. Requiring the explicit import is a good thing I think, this way no variables appear out of thin air which is a lot more transparent for the user.

Just my 2 cents :)

ShaderGenerator doesn't update any TextureStage properties

When the ShaderGenerator is active, changes in TextureStage properties do not show up.

Code sample:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from math import sin, pi


class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)

        # comment out the following to see changes made to the first texture stage
        self.render.set_shader_auto()

        # Setup the camera

        self.cam.set_pos(-7., -10., 4.)
        self.cam.look_at(0., 0., 0.)

        # Create the texture stages

        # the first texture stage should contain a color gradient
        self._ts1 = ts1 = TextureStage("layer1")
        ts1.set_color((1., 0., 0., 1.))
        ts1.set_sort(0)
        ts1.set_combine_rgb(TextureStage.CM_modulate,
                            TextureStage.CS_texture, TextureStage.CO_src_color,
                            TextureStage.CS_previous, TextureStage.CO_src_color)
        # the second texture stage should contain a checker pattern
        self._ts2 = ts2 = TextureStage("layer2")
        ts2.set_sort(1)

        # Create the color gradient

        w = 256
        h = 256
        w_ = 256
        h_ = 256
        rng = h_ / 3.
        img1 = PNMImage(w, h, 4)
        img1.alpha_fill(1.)

        for x in range(w):

            for y in range(h):

                if 0. <= x < rng:
                    # between red and green
                    b = 0.
                    g = x / rng
                    r = 1. - g
                    factor = 1. + sin(g * pi)
                    r *= factor
                    g *= factor
                elif rng <= x < 2. * rng:
                    # between green and blue
                    r = 0.
                    b = (x - rng) / rng
                    g = 1. - b
                    factor = 1. + sin(b * pi)
                    g *= factor
                    b *= factor
                elif 2. * rng <= x < h:
                    # between blue and red
                    g = 0.
                    r = (x - 2. * rng) / rng
                    b = 1. - r
                    factor = 1. + sin(r * pi)
                    b *= factor
                    r *= factor

                img1.set_xel(x, y, r, g, b)

        img_tmp = PNMImage(w, h, 4)
        img_tmp.fill(.5, .5, .5)

        for y in range(h):

            a = 1. * y / h_

            for x in range(w):
                img_tmp.set_alpha(x, y, a)

        img1.blend_sub_image(img_tmp, 0, 0, 0, 0)

        # Create the checker pattern

        w = 256
        h = 256
        w_ = 256
        h_ = 256
        rng = h_ / 4
        img2 = PNMImage(w, h, 4)
        img2.alpha_fill(1.)

        for x in range(w):

            if (x // rng) % 2:

                for y in range(h):

                    if (y // rng) % 2:
                        # blue
                        b = 1.
                        g = r = 0.
                    else:
                        # red
                        r = 1.
                        b = g = 0.

                    img2.set_xel(x, y, r, g, b)

            else:

                for y in range(h):

                    if (y // rng) % 2:
                        # green
                        g = 1.
                        r = b = 0.
                    else:
                        # white
                        r = b = g = 1.

                    img2.set_xel(x, y, r, g, b)

        # Create the geometry and add textures

        cm = CardMaker("quad")
        cm.set_frame(-2., 2., -2., 2.)
        self._quad = quad = self.render.attach_new_node(cm.generate())
        tex1 = Texture("layer1")
        tex1.load(img1)
        tex2 = Texture("layer2")
        tex2.load(img2)
        quad.set_texture(self._ts1, tex1)
        quad.set_texture(self._ts2, tex2)
        quad.set_color((1., 1., 1., 1.))

        self.accept("1", lambda: self.set_property("modulate_ts2"))
        self.accept("2", lambda: self.set_property("replace_ts2"))
        self.accept("3", lambda: self.set_property("add_ts2"))
        self.accept("4", lambda: self.set_property("add_signed_ts2"))
        self.accept("5", lambda: self.set_property("subtract_ts2"))
        self.accept("6", lambda: self.set_property("interpolate_ts2"))
        self.accept("7", lambda: self.set_property("modulate_ts1"))
        self.accept("8", lambda: self.set_property("replace_ts1"))
        self.accept("9", lambda: self.set_property("add_signed_ts1"))
        self.accept("0", lambda: self.set_property("subtract_ts1"))
        self.accept("b", lambda: self.set_property("blend_ts2"))
        self.accept("s", lambda: self.set_property("scale_rgb_ts2"))

    def set_property(self, prop="modulate_ts2"):

        ts1 = self._ts1
        ts2 = self._ts2

        if prop == "modulate_ts2":
            ts2.set_combine_rgb(TextureStage.CM_modulate,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_previous, TextureStage.CO_src_color)
        elif prop == "replace_ts2":
            ts2.set_combine_rgb(TextureStage.CM_replace,
                                TextureStage.CS_texture, TextureStage.CO_src_color)
        elif prop == "add_ts2":
            ts2.set_combine_rgb(TextureStage.CM_add,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_previous, TextureStage.CO_src_color)
        elif prop == "add_signed_ts2":
            ts2.set_combine_rgb(TextureStage.CM_add_signed,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_previous, TextureStage.CO_src_color)
        elif prop == "subtract_ts2":
            ts2.set_combine_rgb(TextureStage.CM_subtract,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_previous, TextureStage.CO_src_color)
        elif prop == "interpolate_ts2":
            ts2.set_combine_rgb(TextureStage.CM_interpolate,
                                TextureStage.CS_last_saved_result, TextureStage.CO_src_color,
                                TextureStage.CS_previous, TextureStage.CO_src_color,
                                TextureStage.CS_texture, TextureStage.CO_src_color)
        elif prop == "modulate_ts1":
            ts1.set_combine_rgb(TextureStage.CM_modulate,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_previous, TextureStage.CO_src_color)
        elif prop == "replace_ts1":
            ts1.set_combine_rgb(TextureStage.CM_replace,
                                TextureStage.CS_texture, TextureStage.CO_one_minus_src_color)
        elif prop == "add_signed_ts1":
            ts1.set_combine_rgb(TextureStage.CM_add_signed,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_constant, TextureStage.CO_src_color)
        elif prop == "subtract_ts1":
            ts1.set_combine_rgb(TextureStage.CM_subtract,
                                TextureStage.CS_texture, TextureStage.CO_src_color,
                                TextureStage.CS_constant, TextureStage.CO_src_color)
        elif prop == "blend_ts2":
            if ts2.get_mode() == TextureStage.M_modulate:
                ts2.set_mode(TextureStage.M_blend)
            else:
                ts2.set_mode(TextureStage.M_modulate)
        elif prop == "scale_rgb_ts2":
            if ts2.get_rgb_scale() == 1:
                ts2.set_rgb_scale(4)
            else:
                ts2.set_rgb_scale(1)


app = MyApp()
app.run()

Press the following keys to change specific properties:

'1': tex. stage 2 combine mode "modulate"
'2': tex. stage 2 combine mode "replace"
'3': tex. stage 2 combine mode "add"
'4': tex. stage 2 combine mode "add_signed"
'5': tex. stage 2 combine mode "subtract"
'6': tex. stage 2 combine mode "interpolate"
'7': tex. stage 1 combine mode "modulate"
'8': tex. stage 1 combine mode "replace"
'9': tex. stage 1 combine mode "add_signed"
'0': tex. stage 1 combine mode "subtract"
'b': tex. stage 2 mode: toggle between "blend" and "modulate"
's': tex. stage 2 rgb scale: toggle between 4 and 1

Actor.getNumFrames IndexError: list index out of range

direct/Actor.py line 899:

def getNumFrames(self, animName=None, partName=None):
        lodName = next(iter(self.__animControlDict))
        controls = self.getAnimControls(animName, partName)
        if len(controls) == 0:
            return None
        return controls[0].getNumFrames()

property 'lodName' is not used and it breaks the function (when my game is compiled to .p3d...)
can this line be removed?

thanks

Shadows not working propperly since built 1144

Hi,
I have some issues when activating shadows after the last updates from the built 1144. They do not work as before. Previously they looked realistic and propperly calculated, while now, it seems like shadows are applied to objects just inside a radius, and actually, quite wrong. I have not changed the code, and installing back the built 1144 everything works fine again. I attach some pictures of a scene with just one cube and a point light (placed where the arrows).
image
image
image

direct.stdpy.threading Threads stay alive

Threads created by from direct.stdpy import threading don't terminate once the run()-Method reaches its end. Replacing that with import threading or from direct.stdpy import threading2 as threading shows the expected behaviour.

Sample program:

from direct.showbase.ShowBase import ShowBase

#import threading
from direct.stdpy import threading
#from direct.stdpy import threading2 as threading

import panda3d.core
from tkinter import Button


class TestWindow:

    def __init__(self):
        base.startTk()
        Button(base.tkRoot, text='Click me', command=self.run_thread).pack()
        Button(base.tkRoot, text='Show num', command=self.show_num).pack()

    def run_thread(self):
        thread = TestThread()
        thread.start()
        # thread.join()     # uncomment this
        print(len(threading.enumerate()))

    def show_num(self):
        print(len(threading.enumerate()))


class TestThread(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        a = panda3d.core.PNMImage(8192, 8192)
        a.addAlpha()
        a.fill(0.5)

        print('End run()-Method of TestThread')


class Main:
    def __init__(self):

        base = ShowBase(windowType='none')

        TestWindow()
        base.run()


if __name__ == '__main__':
    Main()

Observation:
The current number of active threads can be printed out by print(len(threading.enumerate())). Every time a thread is started, this number increases by 1 and should decrease, once the thread finished. Pythons threading-Module and the threading2-Module show the expected behaviour.

.join()-ing the Thread causes it to terminate, the counter will decrease.

Tested on Windows 7 64bit, Python 3.6.2 and a custom compiled Panda3D (current git master).


Here is a simple sample, not involving ShowBase and tkinter. Uncomment the import-statements at the top to switch through the threading-modules:

#import threading
from direct.stdpy import threading
#from direct.stdpy import threading2 as threading

import time


class TestThread(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        print('End run()-Method of TestThread')


if __name__ == '__main__':
    thread = TestThread()
    thread.start()
    # thread.join()     # uncomment this
    print(len(threading.enumerate()))

    time.sleep(5)
    print(len(threading.enumerate()))

Unexplained Panda3D Pipe Errors

I'm unable to work on a Panda3D project because of these random GL/Direct3D errors that came out of nowhere. I was testing out the project with the Panda3D SDK until suddenly I was unable to open the ppython window (I could only see the default windows border for a split-second when I tried to view it) and afterwards I was greeted with startup/init errors. Logs:

:Client: Loading Base...
Known pipe types:
  wglGraphicsPipe
(1 aux display modules not yet loaded.)
:ToonBase: Default graphics pipe is wglGraphicsPipe (OpenGL).
:ToonBase: Got aux graphics pipe wdxGraphicsPipe9 (DirectX9).
:ToonBase: Trying pipe type wdxGraphicsPipe9 (DirectX9)
:display:wdxdisplay9(warning): presentation_params->BackBufferWidth : 148
:display:wdxdisplay9(warning): presentation_params->BackBufferHeight : 0
:display:wdxdisplay9(warning): presentation_params->BackBufferFormat : 21
:display:wdxdisplay9(warning): presentation_params->BackBufferCount : 1
:display:wdxdisplay9(warning): D3D CreateDevice failed for adapter #0 at (c:\users\documents\panda\panda\src\dxgsg9\wdxGraphicsWindow9.cxx:754), hr=E_INVALIDARG: An invalid parameter was passed to the returning function
:ToonBase(warning): Unable to open 'onscreen' window.
Traceback (most recent call last):
  File "C:\Panda3D-1.10.0\python\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Panda3D-1.10.0\python\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "ClientStart.py", line 322, in <module>
    ToonBase.ToonBase()
  File "ToonBase.py", line 41, in __init__
    OTPBase.OTPBase.__init__(self)
  File "OTPBase.py", line 16, in __init__
    ShowBase.__init__(self, windowType = windowType)
  File "C:\Panda3D-1.10.0\direct\showbase\ShowBase.py", line 285, in __init__
    self.openDefaultWindow(startDirect = False, props=props)
  File "C:\Panda3D-1.10.0\direct\showbase\ShowBase.py", line 934, in openDefaultWindow
    self.openMainWindow(*args, **kw)
  File "ToonBase.py", line 381, in openMainWindow
    result = OTPBase.OTPBase.openMainWindow(self, *args, **kw)
  File "OTPBase.py", line 227, in openMainWindow
    result = ShowBase.openMainWindow(self, *args, **kw)
  File "C:\Panda3D-1.10.0\direct\showbase\ShowBase.py", line 970, in openMainWindow
    self.openWindow(*args, **kw)
  File "C:\Panda3D-1.10.0\direct\showbase\ShowBase.py", line 719, in openWindow
    raise Exception('Could not open window.')
Exception: Could not open window.

To make it even stranger, I'm able to run the game completely fine on an embedded Panda3D client. I've already updated my PC, installed the latest NVIDIA graphics drivers for my card, and uninstalled and reinstalled Panda3D. Any insights to what's going on would be greatly appreciated!

Unknown WeakReferenceList crash.

A odd new crash which only started happening after the thread deadlock fixes were made.

I have the call stack here

ntdll.dll!7793cfd6()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] Annotated Frame
[External Code] Annotated Frame
libpandaexpress.dll!WeakReferenceList::add_reference(WeakPointerToVoid * ptv) Line 51 C++ Symbols loaded.
libpandaexpress.dll!ReferenceCount::weak_ref(WeakPointerToVoid * ptv) Line 274 C++ Symbols loaded.
libpandagl.dll!WeakPointerToBase::reassign(TextureAttrib * ptr) Line 70 C++ Symbols loaded.
libpandagl.dll!GLGeomMunger::GLGeomMunger(GraphicsStateGuardian * gsg, const RenderState * state) Line 28 C++ Symbols loaded.
libpandagl.dll!GLGraphicsStateGuardian::make_geom_munger(const RenderState * state, Thread * current_thread) Line 6201 C++ Symbols loaded.
libpanda.dll!GraphicsStateGuardian::get_geom_munger(const RenderState * state, Thread * current_thread) Line 787 C++ Symbols loaded.
libpanda.dll!CullResult::add_object(CullableObject * object, const CullTraverser * traverser) Line 188 C++ Symbols loaded.
libpanda.dll!GeomNode::add_for_draw(CullTraverser * trav, CullTraverserData & data) Line 564 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 181 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!LODNode::cull_callback(CullTraverser * trav, CullTraverserData & data) Line 166 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 237 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse_below(CullTraverserData & data) Line 204 C++ Symbols loaded.
libpanda.dll!CullTraverser::do_traverse(CullTraverserData & data) Line 243 C++ Symbols loaded.
libpanda.dll!CullTraverser::traverse(const NodePath & root) Line 154 C++ Symbols loaded.
libpanda.dll!GraphicsEngine::do_cull(CullHandler * cull_handler, SceneSetup * scene_setup, GraphicsStateGuardian * gsg, Thread * current_thread) Line 1249 C++ Symbols loaded.
libpanda.dll!DisplayRegion::do_cull(CullHandler * cull_handler, SceneSetup * scene_setup, GraphicsStateGuardian * gsg, Thread * current_thread) Line 707 C++ Symbols loaded.
libpanda.dll!GraphicsEngine::cull_to_bins(GraphicsOutput * win, GraphicsStateGuardian * gsg, DisplayRegion * dr, SceneSetup * scene_setup, CullResult * cull_result, Thread * current_thread) Line 1529 C++ Symbols loaded.
libpanda.dll!GraphicsEngine::cull_to_bins(ov_set<PointerTo,IndirectLess,pvector<PointerTo > > wlist, Thread * current_thread) Line 1488 C++ Symbols loaded.
libpanda.dll!GraphicsEngine::WindowRenderer::do_frame(GraphicsEngine * engine, Thread * current_thread) Line 2398 C++ Symbols loaded.
libpanda.dll!GraphicsEngine::render_frame() Line 782 C++ Symbols loaded.
core.pyd!Dtool_GraphicsEngine_render_frame_518(_object * self, _object * __formal) Line 21056 C++ Symbols loaded.
python27.dll!call_function(_object * * * pp_stack, int oparg) Line 4341 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2997 C Symbols loaded.
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * closure) Line 3589 C Symbols loaded.
python27.dll!function_call(_object * func, _object * arg, _object * kw) Line 528 C Symbols loaded.
python27.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2547 C Symbols loaded.
python27.dll!instancemethod_call(_object * func, _object * arg, _object * kw) Line 2600 C Symbols loaded.
python27.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2547 C Symbols loaded.
core.pyd!PythonThread::call_python_func(_object * function, _object * args) Line 137 C++ Symbols loaded.
core.pyd!PythonTask::do_python_task() Line 471 C++ Symbols loaded.
core.pyd!PythonTask::do_task() Line 439 C++ Symbols loaded.
libpanda.dll!AsyncTask::unlock_and_do_task() Line 424 C++ Symbols loaded.
libpanda.dll!AsyncTaskChain::service_one_task(AsyncTaskChain::AsyncTaskChainThread * thread) Line 664 C++ Symbols loaded.
libpanda.dll!AsyncTaskChain::do_poll() Line 1187 C++ Symbols loaded.
libpanda.dll!AsyncTaskManager::poll() Line 480 C++ Symbols loaded.
core.pyd!Dtool_AsyncTaskManager_poll_191(_object * self, _object * __formal) Line 6399 C++ Symbols loaded.
python27.dll!call_function(_object * * * pp_stack, int oparg) Line 4341 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2997 C Symbols loaded.
python27.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4443 C Symbols loaded.
python27.dll!call_function(_object * * * pp_stack, int oparg) Line 4377 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2997 C Symbols loaded.
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * closure) Line 3589 C Symbols loaded.
python27.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4455 C Symbols loaded.
python27.dll!call_function(_object * * * pp_stack, int oparg) Line 4377 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2997 C Symbols loaded.
python27.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4443 C Symbols loaded.
python27.dll!call_function(_object * * * pp_stack, int oparg) Line 4377 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2997 C Symbols loaded.
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * closure) Line 3589 C Symbols loaded.
python27.dll!exec_statement(_frame * f, _object * prog, _object * globals, _object * locals) Line 5075 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2110 C Symbols loaded.
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * closure) Line 3589 C Symbols loaded.
python27.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4455 C Symbols loaded.
python27.dll!call_function(_object * * * pp_stack, int oparg) Line 4377 C Symbols loaded.
python27.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 2997 C Symbols loaded.
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * closure) Line 3589 C Symbols loaded.
python27.dll!function_call(_object * func, _object * arg, _object * kw) Line 528 C Symbols loaded.
python27.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2547 C Symbols loaded.
python27.dll!RunModule(char * module, int set_argv0) Line 197 C Symbols loaded.
python27.dll!Py_Main(int argc, char * * argv) Line 592 C Symbols loaded.
ppython.exe!__tmainCRTStartup() Line 586 C Symbols loaded.
[External Code] Annotated Frame

I have no clue what causes it and it happens at random.

I also have the exception details.

Unhandled exception at 0x7793CFD6 (ntdll.dll) in ppython.exe: 0xC0000005: Access violation writing location 0x00050018. occurred

And finally here's a picture of Visual Studio.

https://prnt.sc/hucsvm

ShaderGenerator doesn't show TextureStage::set_color() changes

While trying to make a luminance slider for a custom color picker, I decided to use multitexturing to decal a semi-transparent black & white gradient texture onto an arbitrarily chosen constant color (changeable by the user). To test out if it would work, I used my own project (Panda3D Studio) to quickly get some results.
Initially it looked like I wanted it, but when I tried to change the color of the first texture stage, the color remained the same. Since I was sure it used to work some time ago, I reverted back to an older version of Panda3D and sure enough, the changes were immediately visible then. It seems to be caused by the ShaderGenerator; when I switch it off, everything works as expected with the newer versions of Panda3D as well.

Here's a small code sample to reproduce the problem:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase


class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)

        # comment out the following to see changes made to the first texture stage
        # using the fixed-function pipeline
        self.render.set_shader_auto()

        # Setup the camera

        self.cam.set_pos(-7., -10., 4.)
        self.cam.look_at(0., 0., 0.)

        # Create the texture stages

        self._ts1 = ts1 = TextureStage("flat_color")
        ts1.set_color((1., 0., 0., 1.))
        ts1.set_sort(0)
        # the first texture stage should show a constant color
        ts1.set_combine_rgb(TextureStage.CM_modulate,
                            TextureStage.CS_constant, TextureStage.CO_src_color,
                            TextureStage.CS_previous, TextureStage.CO_src_color)
        self._ts2 = ts2 = TextureStage("luminance")
        ts2.set_sort(1)
        # the second texture stage should allow the constant color to show through
        # a semi-transparent gradient texture
        ts2.set_mode(TextureStage.M_decal)

        # Create the luminance gradient

        w = 20
        h = 256
        h_ = h - 1
        img = PNMImage(w, h, 4)

        for y in range(h):

            c = 1. if y < h_ / 2 else 0.
            a = 1. - 2. * y / h_ if y < h_ / 2 else 2. * y / h_ - 1.

            for x in range(w):
                img.set_xel(x, y, c, c, c)
                img.set_alpha(x, y, a)

        # Create the geometry and add textures

        cm = CardMaker("lum_quad")
        cm.set_frame(-.5, .5, -2., 2.)
        quad = self.render.attach_new_node(cm.generate())
        tex = Texture("luminance")
        tex.load(img)
        quad.set_texture(self._ts1, Texture(""))
        quad.set_texture(self._ts2, tex)

        self.accept("r", lambda: self.change_color((1., 0., 0., 1.)))
        self.accept("g", lambda: self.change_color((0., 1., 0., 1.)))
        self.accept("b", lambda: self.change_color((0., 0., 1., 1.)))

    def change_color(self, color):

        self._ts1.set_color(color)


app = MyApp()
app.run()

When you run the code, you should see a rectangle with a gradient going from white at the top to red in the middle, to black at the bottom. When you press 'R', 'G' or 'B' on the keyboard, the middle color on the rectangle should change to red, green or blue respectively. Without the ShaderGenerator it should always work, but with newer Panda3D versions it doesn't work when the ShaderGenerator is used.

Other property changes of the first texture stage did not show up either, e.g. combine mode parameters.

There were no problems with Panda3D version 560fd4e (2017-05-13), but from version f79fbf2 (2017-07-10) onward the issue appeared (I did not try other versions in between).

This happens on Windows 8.1 64-bit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.