Yarr2 multitextured mode terrain don't gets light (?)

ok, i just was trying to be able to render a geomipmapterrain with multitexture without having (still) any knowledge about shaders.

so i found the Yarr2 demo and i said to myself -Wow, this really does what i want!-, but then i realized the following:

-if you set the terrain to monoTexture, the terrain shows itself iluminated by the directional light and tinted by the ambient light

  • if set it to multiTexture dough only ambient light brightness seem to be affecting the terrain

I was hoping if anyone could give me a hand on that, so would be really a nice starting environment for my project


If a shader is applied, lighting won’t show up, unless you do the lighting yourself in the shader.

but it seems like some light code is already implemented, called by this:

# make lights available to the terrain shader
self.root.setShaderInput('lightvec', Vec4(0.7, 0.2, -0.2, 1))
self.root.setShaderInput('lightcolor', self.direct)
self.root.setShaderInput('ambientlight', self.ambient)

this is the terrain shader:

//Cg profile arbvp1 arbfp1

// shader loosely based on pro-rsoft's from the panda3d forums
// shader assumes 6 texture stages:
// 0-2 textures
// 3-5 alpha maps
// vertex shader accepts unit 0 and 3 texture coords as input 
// and outputs unit 0 scaled and unit 3 unchanged
// fragment shader uses unit 0 coordinates to access textures
// and unit 3 coordinates (un-scaled) to access alpha maps
// gsk, june-2008

void vshader( in float4 vtx_position : POSITION,
	      in float3 vtx_normal : NORMAL,
              in float2 vtx_texcoord0 : TEXCOORD0,
              in float2 vtx_texcoord3 : TEXCOORD3,
              in uniform float4x4 mat_modelproj,
	      in uniform float4 k_lightvec,
	      in uniform float4 k_lightcolor,
	      in uniform float4 k_ambientlight,
	      in uniform float4 k_tscale, 
	      out float l_brightness,
              out float2 l_texcoord0 : TEXCOORD0,
              out float2 l_texcoord3 : TEXCOORD3,
              out float4 l_position : POSITION)


  // lighting
  float3 N = normalize( vtx_normal );
  float3 L = normalize( k_lightvec.xyz );
  l_brightness = (max( dot( -N, L ), 0.0f )*k_lightcolor)+k_ambientlight;


void fshader( in float4 l_position : POSITION,
              in float2 l_texcoord0 : TEXCOORD0,
              in float2 l_texcoord3 : TEXCOORD3,
	      in float  l_brightness,
              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,
              in uniform sampler2D tex_5 : TEXUNIT5,
              out float4 o_color : COLOR )
  float4 tex1=tex2D(tex_0,l_texcoord0);
  float4 tex2=tex2D(tex_1,l_texcoord0);
  float4 tex3=tex2D(tex_2,l_texcoord0);
  float alpha1=tex2D(tex_3,l_texcoord3).z;
  float alpha2=tex2D(tex_4,l_texcoord3).z;
  float alpha3=tex2D(tex_5,l_texcoord3).z;
  o_color =tex1*alpha1;

just wanted to make shure lights wont work with this…

ah, self.direct and self.ambient are lights created in panda.

well, just decided to move on and discovered this post about panda+earthsculptor:


wich looks quite promising for some multitextured geomipterrain implementation

let’s see!