Thanks for you reply. I read that with the k_ prefix here as well but if i delete the prefixes even more errors of a similar type are shown (probably they were just hidden by the k_ prefix).
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in float3 material.Ke)
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in float3 material.Ka)
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in float3 material.Kd)
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in float3 material.Ks)
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in unknown material.shininess)
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in float3 globalAmbient)
:gobj(error): shaders/BasicShader.sha: invalid parameter name (uniform in float3 eyePosition)
Is it even a panda-pythonic way to submit shader variables with a struct? In the Cg-Tutorial it’s advised to use input and output structures, as well as functions to keep the code cleaner but that doesn’t seem to work well together with panda.
Edit:
I just tried it with a smaller shader and the k_ prefix is definitely needed in the shader file but not in the python file.
This is the working example without structs:
//Cg
struct simpleTextureOutputVertex
{
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
simpleTextureOutputVertex vshader(float4 vtx_position : POSITION,
in float2 vtx_texcoord0: TEXCOORD0,
uniform float4x4 mat_modelproj)
{
simpleTextureOutputVertex OUT;
OUT.position=mul(mat_modelproj, vtx_position);
OUT.texcoord0 = vtx_texcoord0;
return OUT;
}
void fshader(uniform sampler2D tex_0,
uniform float3 k_acol,
in float2 l_texcoord0:TEXCOORD0,
out float4 o_color:COLOR0)
{
float4 fullColor = tex2D(tex_0, l_texcoord0);
float3 rgb = fullColor.xyz*k_acol;
o_color = float4(rgb, fullColor.w);
}
myShader = Shader.load("shaders/directionalLight.sha")
render.setShaderInput('acol', 1.0,0.8,0.2)
render.setShader(myShader)
The assignment of a Vec3 with setShaderInput didn’t work either