Hey everyone,
So I’m currently learning about shaders in panda3d and I’m trying to develop a shader that would imitate the behavior of a converging lens.
The idea is following : I first compute the image point V’ of the vertex V using the parameters of the lens. Then I build the intersection of the lines that go from the edge of the lens to V’ with the screen which allows me to get the points that defines the boundaries of the patch which is the image of the vertex on the screen through the lens.
So in order to get all of it working I use the vertex shader to project V into the View Coordinates. Then I compute V’ (for example), then the geometry shader computes the points that define the boundaries of the patch and returns a triangle strip of the color of the original vertex that represents the image.
So I’ve already played with the vertex and the fragment shaders but it’s the first time that I’m getting involved with the geometry shader and I just can’t figure out how to make it work : when loading the shader in a very simple script I get the following error
:display:gsg:glgsg(error): Could not create a GLSL geometry shader.
Here is the code for the simple vertex, geom, and frag shaders that I’m trying to get working. Note that everything works fine without the geom shader.
shader.vert
#version 130
uniform mat4 p3d_ModelViewProjectionMatrix;
in vec4 p3d_Vertex;
void main() {
gl_Position = p3d_ModelViewProjectionMatrix*p3d_Vertex;
}
shader.geom
#version 130
layout (points) in;
layout (line_strip, max_vertices=2) out;
void main() {
gl_Position = gl_in[0].gl_Position + vec4(-.1, 0, 0, 0);
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(.1, 0, 0, 0);
EmitVertex();
EndPrimitive();
}
shader.frag
#version 130
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
OS : Ubuntu 18.04 LTS
Panda3D Version : 1.10 (I think) (I installed it using pip3 last week)
Output of the lspci command :
00:00.0 Host bridge: Intel Corporation Atom Processor Z36xxx/Z37xxx Series SoC Transaction Register (rev 0e) 00:02.0 VGA compatible controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Graphics & Display (rev 0e) 00:13.0 SATA controller: Intel Corporation Atom Processor E3800 Series SATA AHCI Controller (rev 0e) 00:14.0 USB controller: Intel Corporation Atom Processor Z36xxx/Z37xxx, Celeron N2000 Series USB xHCI (rev 0e) 00:1a.0 Encryption controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine (rev 0e) 00:1b.0 Audio device: Intel Corporation Atom Processor Z36xxx/Z37xxx Series High Definition Audio Controller (rev 0e) 00:1c.0 PCI bridge: Intel Corporation Atom Processor E3800 Series PCI Express Root Port 1 (rev 0e) 00:1c.1 PCI bridge: Intel Corporation Atom Processor E3800 Series PCI Express Root Port 2 (rev 0e) 00:1f.0 ISA bridge: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Power Control Unit (rev 0e) 00:1f.3 SMBus: Intel Corporation Atom Processor E3800 Series SMBus Controller (rev 0e) 01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15) 02:00.0 Network controller: Intel Corporation Wireless 3160 (rev 93)
So does anyone know anything about the geometry shaders not working in this configuration ? And are geometry shaders absolutely necessary for my current project ?
Thank you very much for your help.