render.setShaderAuto() having no effect

Hi, I’m new to the community. I am a fairly experienced programmer looking to familiarize myself with panda3d. I’m working with the engine in python, installed with pip in vscode.

I’m following along this tutorial by Thaumaturge, but the line “render.setShaderAuto()” has no effect on how the models are rendered in my game window. I’m hoping someone more familiar with the engine can help me out. The code I’m running is a near exact copy of that on Thaumaturge’s github linked at the bottom of the tutorial. I’ve even copied it in exactly to test if there was a problem in the code, but that seems to have been ruled out. Any ideas?

Hello, I’m glad you’re interested in using Panda3D. It’s not always the most straightforward engine to use. That being said, I think we could use a little bit more detail about your setup.

Now, your models – did you make them in Blender or so? What format are they? How are you loading them into your scene?

Keep in mind that set_shader_auto() (or setShaderAuto() as it were) is not intended to be a modern renderer solution. So if you want to do PBR rendering for instance we could recommend different solutions.

Of course, Thaumaturge may like to weigh in considering the question is mainly about their specific tutorial.

Greetings, and welcome to the community! I hope that you find your time here to be enjoyable and helpful! :slight_smile:

So, as to the tutorial and “setShaderAuto”, let me ask a few things to start with:

  • First, are you using the models from the tutorial, or other models?

  • Second, what output are you seeing in the console?

  • Third, what version of Panda are you using?

  • Fourth, what are you system specs?

  • And finally, have you modified the Panda3D configuration files (i.e. the “.prc” files) at all?

This is true!

Still, I do think that “setShaderAuto” is perhaps a good place to start when learning the engine, as it’s a simple way to get better-than-unshaded rendering.

If you look more deeply at the alleged problem. Then set_shader_auto() requires the presence of certain maps assigned to your model, and also requires the presence of data at the vertices, such as tangents and bionormals. It looks like you didn’t comply with this requirement…

Hi, thank you for the response! Great tutorial by the way–it’s very helpful. I’ll address the question in order:

  1. The environment model is from the tutorial. The character model is different but the shader isn’t rendering on either.
  2. This is all I get in the console: “Known pipe types: CocoaGraphicsPipe (all display modules loaded.)” No warnings or errors.
  3. Current 1.10.14
  4. At the moment I’m on a macOS 12.4. I’m away from my PC so I haven’t been able to try it there. If this is the problem, it would be music to my ears.
  5. No, not at all.

Thanks!

I thought that might have been the problem at first too, but the .egg file I’m using contains the required vertices data. That being said, I’ve never had to really dig into shaders in the past.

Thanks for the reply! I’m really enjoying the engine and the community.

I have an environment and character model, both in .egg format. The environment model is from Thaumaturge’s tutorial and the character model is the engine model of the panda mascot. Both load and render fine with loader.loadModel(fileDir) and the reparentTo(render) methods.

Hmm, very strange!

I’d very much like to know what happens on a non-macOS device.

I’m wondering in particular whether, under Mac (or perhaps certain versions of Cocoa), Panda isn’t set up to use OpenGL’s “core profile” rather than the usual “compatibility” one. As I understand it, the auto-shader doesn’t work under the former, while it does work under the latter.

(Apparently the auto-shader not working with the “core profile” is due to change with Panda 1.11–but it’s not clear to me whether the fix has yet been implemented, and thus whether trying a development build of 1.11 would be a useful test.)

This is, however, just speculation! I’m hoping that one of those deeper in the depths of the engine might weigh in…

[edit]
Oh, and thank you for your kind words on the tutorial! I’m very glad that it’s proving helpful! :slight_smile:

Also, two tests that seem like they might be worthwhile:

  • In the Panda samples (see the download page, if you don’t already have them), does the “Bump-Mapping” demo show, well, bumpiness?

  • If you open the environment model in PView (e.g. by opening a terminal/console to the directory that holds the environment model and typing in “pview environment.egg”), then enable lighting by pressing “L” and per-pixel lighting by pressing “P”, is the model lit and normal-mapped?

Good idea! Here are the results from the tests.

  • The Bump-Mapping demo outputs “Video driver reports that shaders are not supported.”

  • Lighting works in PView but per-pixel lighting doesn’t respond.

It looks like the problem is definitely stemming from running the program on Mac. I found this discussion on github while doing some research on the error. I’m using an M2 chip, but I imagine the solution is similar.

[Edit - Solution]

After some more research, the problem is that Cg shader support is not on ARM based machines like mac m1 and m2. The problem is to use GLSL shaders, which will obviously be a bar for many people but is a good learning experience if you have the time. Luckily for us, Panda3d 1.11 will fix this! The engine will be moving away from Cg shaders anyway, so it’s a good time to start looking at GLSL.

For anyone interested in this problem, here is a link to Panda3d documentation that explains using shaders in the engine on macOS (and more). Thank you to everyone for their help, I’m going to mark this as solved!

2 Likes