Hello everyone, I wanted to ask some questions on panda3d GLSL and CG shader code differences below is a old Cg shader that I use a lot, I read that panda3d will be soon dropping support for the Cg shading language.

Not wanting to lose the look of my game I have decided to a take GLSL language course so I can port the shader myself

```
//Cg
void vshader(
float4 vtx_position : POSITION,
float2 vtx_texcoord0 : TEXCOORD0,
float3 vtx_normal : NORMAL,
uniform float4x4 mat_modelproj,
uniform float4x4 trans_model_to_world,
uniform float4 mspos_cam,
uniform float4 AmbLight,
out float l_smooth,
out float l_facingRatio,
out float2 l_texcoord0 : TEXCOORD0,
out float3 l_texcoord1 : TEXCOORD1,
out float4 l_position : POSITION
)
{
l_smooth = smoothstep( AmbLight,1,dot(vtx_normal, normalize(mspos_cam-vtx_position)) );
l_facingRatio = pow( 1.0-saturate( dot(vtx_normal, normalize(mspos_cam-vtx_position)) ), 4 );
l_position = mul(mat_modelproj, vtx_position);
l_texcoord0=vtx_texcoord0;
l_texcoord1=mul(trans_model_to_world, float4(vtx_normal,0)).xyz;
}
void fshader(
in float2 l_texcoord0: TEXCOORD0,
in float3 l_texcoord1: TEXCOORD1,
in float l_smooth,
in float l_facingRatio,
uniform float4 k_DirLight,
uniform samplerCUBE k_envirCubeMap,
sampler2D tex_0 : TEXUNIT0,
out float4 o_color:COLOR)
{
float4 tex = tex2D(tex_0, l_texcoord0);
float3 cubeMap = texCUBE(k_envirCubeMap,l_texcoord1).xyz * k_DirLight.x;
o_color = float4( lerp(tex.rgb*l_smooth, (tex.rgb+cubeMap)*.5, l_facingRatio) , tex.a );
}
```

I actually got the shader from a vary old thread here Mario Galaxy-style velvet shader? - General Discussion - Panda3D now, my attempt is below, the vert shader.

```
#version 150 // vertex shader
uniform mat4 p3d_ModelViewProjectionMatrix;
uniform mat4 p3d_ModelMatrix;
uniform vec4 mspos_cam;
uniform vec4 AmbLight;
in vec4 p3d_Vertex;
in vec2 p3d_MultiTexCoord0;
in vec3 p3d_Normal;
out float l_smooth;
out float l_facingRatio;
out vec2 li_TexCoord0;
out vec3 li_TexCoord1;
void main() {
vec3 lhtsrc = mspos_cam.xyz;
l_smooth = smoothstep(AmbLight[0], 1.0, dot(p3d_Normal, normalize(lhtsrc - p3d_Vertex.xyz)));
vec3 viwsrc = mspos_cam.xyz;
l_facingRatio = pow(1.0 - clamp(dot(p3d_Normal, normalize(viwsrc - p3d_Vertex.xyz)), 0.0, 1.0), 4.0);
vec4 l_position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
gl_Position = l_position;
li_TexCoord0 = p3d_MultiTexCoord0;
li_TexCoord1 = vec3(p3d_ModelMatrix * vec4(p3d_Normal, 0.0));
}
```

then the frag shader

```
#version 150 // fragment shader
uniform vec4 DirLight;
uniform samplerCube envirCubeMap;
uniform sampler2D p3d_Texture0;
in float l_smooth;
in float l_facingRatio;
in vec2 li_TexCoord0;
in vec3 li_TexCoord1;
out vec4 FragColor;
vec4 tex;
vec3 mixed;
void main() {
vec4 tex = texture(p3d_Texture0, li_TexCoord0);
vec3 cubeMap = texture(envirCubeMap, li_TexCoord1).rbg * DirLight[0];
vec3 mixed = (tex.rgb * l_smooth) * (1.0 - l_facingRatio) + ((tex.rgb + cubeMap) * .5) * l_facingRatio;
FragColor = vec4(mixed, tex.r);
}
```

the questions I wanted to ask was

1: is mat_modelproj and trans_model_to_world something in the control program? I ask because there are no shader inputs for them and no Cg commands for them in the list, yet they somehow work (this has been solved by Thaumaturge)

2: I need to know how to get nodes into the shader and also get their position like the original Cg shader, it was done with a shader input for the node then in the shader itself, uniform float4 (vec4 for GLSL) mspos_ then the shader input name (solved by Thaumaturge, but waiting confirmation)

3: a little embarrassing, but is there GLSL command equivalent to Cg mul()? (doing some research, I found this to be multiplying matrices by a vec3, which was completely over my head and even glsl has trouble doing this)

a thank you to anyone who could help, have a good one guys