Missing transforms for shaders?

Hi,

I am having some problems with some shader code. I am using panda3d 1.8.1, on a Linux machine.

I have the following GLSL fragment shader:

uniform float coefficient;
uniform float power;
uniform vec3  glowColor;
varying vec3  vNormal;
varying vec3  vWorld;
uniform vec3  cameraPosition;
uniform mat4  trans_world_to_view;

void main() {
	float intensity = 1.0;
	vec3 worldCameraToVertex = vWorld.xyz - cameraPosition;
	vec3 viewCameraToVertex  = (trans_world_to_view * vec4(worldCameraToVertex, 0.0)).xyz;
	viewCameraToVertex = normalize(viewCameraToVertex);
	intensity = pow( coefficient + dot(vNormal.xyz, viewCameraToVertex), power );
	gl_FragColor = vec4( glowColor, intensity );
	/*gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );*/
}

In the code above I am using “trans_world_to_view” since I need to transform from world coordinates to camera coordinates. The problem is that when I run the program, panda3d has problems and cannot find this matrix:

Assertion failed: Shader input trans_world_to_view is not present.
 at line 466 of panda/src/pgraph/shaderAttrib.cxx
Assertion failed: !np.is_empty() at line 1169 of panda/src/display/graphicsStateGuardian.cxx
Assertion failed: Shader input trans_world_to_view is not present.
 at line 466 of panda/src/pgraph/shaderAttrib.cxx
Assertion failed: !np.is_empty() at line 1169 of panda/src/display/graphicsStateGuardian.cxx
Traceback (most recent call last):
  File "/usr/share/panda3d/direct/showbase/ShowBase.py", line 1846, in __igLoop
    self.graphicsEngine.renderFrame()
AssertionError: Shader input trans_world_to_view is not present.
 at line 466 of panda/src/pgraph/shaderAttrib.cxx
:task(error): Exception occurred in PythonTask igLoop
Traceback (most recent call last):
  File "sfc_main.py", line 456, in <module>
    sfc.run()
  File "/usr/share/panda3d/direct/showbase/ShowBase.py", line 2921, in run
    self.taskMgr.run()
  File "/usr/share/panda3d/direct/task/Task.py", line 502, in run
    self.step()
  File "/usr/share/panda3d/direct/task/Task.py", line 460, in step
    self.mgr.poll()
  File "/usr/share/panda3d/direct/showbase/ShowBase.py", line 1846, in __igLoop
    self.graphicsEngine.renderFrame()
AssertionError: Shader input trans_world_to_view is not present.
 at line 466 of panda/src/pgraph/shaderAttrib.cxx

What is going wrong? Am I doing a mistake somewhere? Or is it a Panda3d problem? My understanding reading the manual was that these transformation are always available: is there an alternative?

Thanks in advance

Hi, welcome to the forums!

You may need to use a development build of Panda3D, which improves GLSL support.

It’s better to use these matrices instead when possible:
panda3d.org/manual/index.ph … der_Inputs

Thanks! :smiley:

Ok then, I will install the devel version.