Hi, quick follow-up with a bit more context.
First of all, I managed to resolve the previous issue (the shaders import collision) - that part was entirely on my side.
My project already had its own top-level shaders/ directory with custom GLSL code, so when p3dimgui does:
from shaders import *
it naturally collided with my own module. As a quick workaround, I renamed my project directory to custom_shaders, and everything works fine now.
That said, it would still be really nice if this could be handled on the p3dimgui side, so it doesn’t rely on such a common and obvious module name as shaders. Namespacing this would probably avoid similar issues for other users.
After fixing that, I ran into a second, separate issue related to GLSL versions.
The backend currently ships with GLSL 1.20 shaders, which works fine as long as Panda3D runs in a legacy/compatibility profile. In my project I explicitly force:
loadPrcFileData("", "gl-version 4 1")
because my rendering pipeline relies on a 4.1. In that case, the ImGui shaders fail to compile (which is expected), since GLSL 120 is not supported in a 4.1 context.
I fixed this locally by rewriting the shaders from GLSL 1.20 to GLSL 4.10. After that, everything works correctly. So effectively it’s an “either legacy GL or updated shaders” situation.
For reference, this is the modified shader code I’m currently using:
FRAG_SHADER = """
#version 410
in vec2 texcoord;
in vec4 color;
uniform sampler2D p3d_Texture0;
out vec4 fragColor;
void main()
{
fragColor = color * texture(p3d_Texture0, texcoord);
}
"""
VERT_SHADER = """
#version 410
// Panda3D-provided vertex inputs
layout(location = 0) in vec4 p3d_Vertex; // { vec2 pos, vec2 uv }
layout(location = 1) in vec4 p3d_Color;
// Outputs to fragment shader
out vec2 texcoord;
out vec4 color;
// Panda3D-provided uniform
uniform mat4 p3d_ModelViewProjectionMatrix;
void main()
{
texcoord = p3d_Vertex.zw;
color = p3d_Color.bgra;
gl_Position =
p3d_ModelViewProjectionMatrix *
vec4(p3d_Vertex.x, 0.0, -p3d_Vertex.y, 1.0);
}
"""
Obviously, this is still a dirty hack on my side. Ideally, it would be great if the backend could detect the active OpenGL/GLSL version (or whether Panda3D is running in a core vs compatibility profile) and automatically select appropriate shader variants.
Just documenting this in case someone else runs into the same combination of issues.