Hi,
I’m trying to do some basic lighting on my texture splatted geomipterrain.
The texture splatting works fine, and so does the ambient light, but I can’t get Panda to recognise the directional light.
Here’s the code where I setup the shader:
tAlphaTexture = loader.loadTexture("assets/terrainalpha.png")
t0Texture = loader.loadTexture("assets/earthrough.jpg")
t1Texture = loader.loadTexture("assets/grass.jpg")
t2Texture = loader.loadTexture("assets/rockgrassy.jpg")
t3Texture = loader.loadTexture("assets/groundplants.jpg")
terrainShader = Shader.load("terrainSplatLit.cg")
root.setShader(terrainShader)
# add lights for shader
root.setShaderInput('dlight',self.dlnp)
root.setShaderInput('alight',self.alnp)
# four textures and an alpha map for the texture splatter
root.setTexture(TextureStage('tex0'),t0Texture,10)
root.setTexture(TextureStage('tex1'),t1Texture,10)
root.setTexture(TextureStage('tex2'),t2Texture,10)
root.setTexture(TextureStage('tex3'),t3Texture,10)
root.setTexture(TextureStage('tex4'),tAlphaTexture,10)
And here’s the shader
void vshader( in float4 vtx_position : POSITION,
in float3 vtx_normal : NORMAL,
in float2 vtx_texcoord0 : TEXCOORD0,
in uniform float4x4 mat_modelproj,
out float2 l_texcoord0 : TEXCOORD0,
out float2 l_texcoord1 : TEXCOORD1,
out float3 l_texcoord2 : TEXCOORD2, // object position
out float3 l_texcoord3 : TEXCOORD3, // normal
out float4 l_position : POSITION)
{
l_position=mul(mat_modelproj,vtx_position);
l_texcoord0 = vtx_texcoord0*20;
l_texcoord1 = vtx_texcoord0;
l_texcoord2 = vtx_position.xyz;
l_texcoord3 = vtx_normal;
}
void fshader( in float2 l_texcoord0 : TEXCOORD0,
in float2 l_texcoord1 : TEXCOORD1,
in float3 l_texcoord2 : TEXCOORD2, // object position
in float3 l_texcoord3 : TEXCOORD3, // normal
in float4 l_position : POSITION,
in uniform float4x4 dlight_dlight,
in uniform float4 alight_alight,
in uniform sampler2D tex_0 : TEXUNIT0,
in uniform sampler2D tex_1 : TEXUNIT1,
in uniform sampler2D tex_2 : TEXUNIT2,
in uniform sampler2D tex_3 : TEXUNIT3,
in uniform sampler2D tex_4 : TEXUNIT4,
out float4 o_color : COLOR )
{
// calculate texture
float4 tex0=tex2D(tex_0,l_texcoord0);
float4 tex1=tex2D(tex_1,l_texcoord0);
float4 tex2=tex2D(tex_2,l_texcoord0);
float4 tex3=tex2D(tex_3,l_texcoord0);
float4 alpha=tex2D(tex_4,l_texcoord1);
o_color =tex0;
o_color=tex1*alpha.x+(1-alpha.x)*o_color;
o_color=tex2*alpha.y+(1-alpha.y)*o_color;
o_color=tex3*alpha.z+(1-alpha.z)*o_color;
o_color.a=1.0;
// calculate lighting
float3 P = l_position.xyz;
float3 N = normalize(l_texcoord3);
// ambient term
float3 ambient = alight_alight.xyz;
// rest is commented out for now
When I run this I get the following error:
:gobj(error): terrainSplatLit.cg: Keyword 'to' or 'rel' expected (uniform in float4x4 dlight_dlight)
Anybody have any ideas?